This Time Self-Hosted
dark mode light mode Search

Sometimes the warnings can make things worse

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.

Comments 1
  1. How bout adding the change to autoconf only conditionally? Based on config option it would either define zeroes (new behavior), or nothing as previously. So you would enable this option only in converted projects.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.