On Fri, 22 Feb 2019 at 15:43, David Brown <david@xxxxxxxxxxxxxxx> wrote: > > On 22/02/2019 15:29, Jonny Grant wrote: > > Would be goundefined. After all replacements due to macro expansion and the defined unary operator have been performed, all remaining identifiers (including those lexically identical to keywords) are replaced with the pp-number 0, and then each preprocessing token is converted into a token. The resulting tokens compose the controlling constant od for -Wundef to be on by default > > > > We see a few times code silently left out of a build unless we use -Wundef > > > > Example below, the bug is this file didn't have a #define PROJ_DEF 1 > > > > Jonny > > > > // gcc -Wall -Wextra -c pre.c > > #include <stdio.h> > > int main() > > { > > #if PROJ_DEF > > printf("hello\n"); > > #endif > > > > return 0; > > } > > > > I think far too much code relies on this sort of construct and would > throw up warnings while otherwise passing -Wall cleanly. > > As far as I can see from the C standards, using "#if PROJ_DEF" without > defining the macro "PROJ_DEF" is not allowed, but I could be wrong - and > it certainly has been common usage even if the standards disallow it. It's absolutely fine according to the standards: After all replacements due to macro expansion and the defined unary operator have been performed, all remaining identifiers (including those lexically identical to keywords) are replaced with the pp-number 0, and then each preprocessing token is converted into a token. In most codebases -Wundef is far too noisy for -Wall.