On 14.04.2013 23:09, Evan Nemerson wrote:
> On Sun, 2013-04-14 at 18:38 +0200, Alexander Krivács Schrøder wrote:
>> Hi.
>>
>> I'm trying to use Glib.TimeVal with its from_iso8601() initializer, but
>> I can't get the generated C code not to contain a call to
>> g_get_current_time() first. At first, I tried this Vala code:
>>
>> string iso8601_date = "1999-05-31T11:20:00";
>> TimeVal time_val;
>> time_val.from_iso8601(iso8601_date);
>>
>> but that makes the compiler complain:
>>
>> error: use of possibly unassigned local variable `time_val'
>>
>> So then I tried this code:
>>
>> string iso8601_date = "1999-05-31T11:20:00";
>> TimeVal time_val = TimeVal();
>> time_val.from_iso8601(iso8601_date);
>>
>> but that makes the compiler output the following code:
>>
>> g_get_current_time (&time_val);
>> g_time_val_from_iso8601 (iso8601_date, &time_val);
>>
>> What do I do to make it not call g_get_current_time()? I know it's
>> probably minimal, but it's still wasted CPU cycles and extraneous code
>> to compile and whatnot, and I want the option to leave it out if at all
>> possible. If it isn't possible, a way to make it possible should be
>> considered to be implemented.
> TimeVal time_val = {};
> time_val.from_iso8601 (iso8601_date);
>
>
> -Evan
>
Thank you, that did the trick. :) Exactly the behavior I was looking for
in the C code.

Regards,
Alexander K. Schrøder

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to