[Date Prev][Date Next]
[Chronological]
[Thread]
[Top]
Re: (ITS#4948) #if/#elif argument in .../include/ac/time.h
lucio@proxima.alt.za writes:
> Whether the existing format is legitimate or not is a matter for the C
> standards, but I believe that the alternative would be both clearer
> and more portable.
It's legitimate. In #if/#elif statements, an undefined macro
(without arguments) has the value 0 in a correct compiler.
That said, it's indeed a reasonable cleanup. I'll do that and some
others shortly. Allows us to compile with 'gcc -Wundef' without
too much noise too.
I'll tests I'm not sure about alone (in particular Windows stuff), in
case it's supposed to be OK to compile with '-D<macro name>=0' so a
change from #if to #ifdef would change OpenLDAP's behavior. Maybe
someone else can have a look at that.
> The Plan 9 C pre-processor has a definite issue with it and it seems a
> reasonable change to implement. There may be other places where a
> similar change would be beneficial, I'll identify them as I
> encountered and will provide a comprehensive list on demand.
Please be specific: Give the exact error/warning message, and make clear
whether it _is_ a warning or an error.
BTW, will 9 C accept this (when you do not define FOO/BAR)? What
error/warning messages, if any?
#if defined(FOO) && FOO /* Guard #if FOO with defined(FOO) */
int main() { return 2; }
#elif BAR
int main() { return 1; }
#else
int main() { return 0; }
#endif
--
Regards,
Hallvard