Today's patches
Julien ÉLIE
julien at trigofacile.com
Sun May 24 14:00:19 UTC 2015
Hi Russ,
>> I have just checked how these structs are currently used, to confirm
>> that it is OK to initialize all of them with 0.
>> The initialization is now done this way:
>> ARTHANDLE newart = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
>
>> I hope it is fine this way (that is to say "0" instead of "NULL"
>> for pointers is portable enough).
>
> Yup, that's fine. The only place you can't use 0 (or NULL) is when
> passing in a NULL pointer to a variadic function, in which case you need
> to explicitly cast it to the appropriate pointer type, such as (char *) 0.
> And that's because the compiler can't know the type of the argument.
> Here, the compiler knows, and can translate 0 without any difficulty.
OK, thanks for the explanation.
> A common C convention is to define some preprocessor symbol to the
> initializer for the data structure so that you can update it in only one
> place if you ever change the data structure (preferrably in the same
> header that defines the data structure). Like, for example,
> PTHREAD_MUTEX_INITIALIZER.
Adopted. It will indeed be easier to maintain.
--
Julien ÉLIE
« – Vous ramassez des champignons sans les connaître ?
– Et alors ? Ce n'est pas pour les manger mais pour les vendre. »
More information about the inn-workers
mailing list