Rusty Russsel writes about using -Wundef and replacing #ifdef with #if to avoid errors while writing preprocessor directives.
Unfortunately, this is not always an option; while he has a point that in theory that would work better, a lot of projects are constrained by autoconf setups. Autoconf creates a config.h file where HAVE_FOO symbols are defined, but only if their value is 1.
This means that following Rusty’s advise, you’d end up with an autoconf project full of warnings in every conditional path that is not enabled at that point.
Unfortunately, to fix this in autoconf so that it properly define the values to zero, would require basically any software project using it to rewrite all its conditionals, so it’s not really something that it’s likely to be available in a short time.
But of course that suggestion is useful for custom-built setups, and now that I think of it, that would have saved me from a mistake last week when I was working on ruby-hunspell as I forgot to define HAVE_VISIBILITY. I think I’ll try that today.