lucio@proxima.alt.za writes:
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.
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