[Vala] ellipsis forwarding



Hello

Is there anybody who made has some experiences with ellipsis?
I wrote the following code:
____

void add_vals(string first_property_name, ...) {
        var l = va_list();
        print("\n1:\t%s-%s\n\t%s-%s\n\n",first_property_name,
                 l.arg<string>(), l.arg<string>(), l.arg<string>());
        add_vals_valist(first_property_name, l);
}

void add_vals_valist(string first_property_name, ...) {
        var l = va_list();
        print("\n2:\t%s-%s\n\t%s-%s\n\n", first_property_name, 
               l.arg<string>(), l.arg<string>(), l.arg<string>());
}

static int main() {
        add_vals(
                "first",  "first_val",
                "second", "second_val",
                "3rd", "3rd_val",
                null
        );
        return 0;
}

____

It leads to the following output:
$./ellipsis_forwarding 

1:      first-second_val
        second-first_val

[Invalid UTF-8] 
2:      first-second
        (null)-\xea\x87\x04\x08\xe2\x87\x04\x08

So, I have two problems: 
- First, I do not understand why the order of the values changed.
- Second, I cannot see why the forwarding of the va_args does not work.

Can anybody give me a hint?

Regards
Jörn




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]