Dear LazyWeb, autoconf and #define HAVE_ 0

How do I make an existing project (let’s say, MySQL) switch from generating a config.h that has #undef HAVE_FOO to one that generates #define HAVE_FOO 0 instead?

Why? Well, here’s why:

Testing for features should be done by including “config.h” and using #if HAVE_<feature>. Use of #if (rather than #ifdef) allows the gcc -Wundef flag to warn users about features which aren’t defined 1 or 0 in config.h.

4 thoughts on “Dear LazyWeb, autoconf and #define HAVE_ 0

  1. Pingback: Dear LazyWeb, autoconf and #define HAVE_ …

  2. To make it so, you need something like this in

    PKG_CHECK_MODULES(SNDFILE, sndfile >= 1.0.6, ac_cv_sndfile=1, ac_cv_sndfile=0)
    AC_DEFINE_UNQUOTED([HAVE_SNDFILE],$ac_cv_sndfile,[Set to 1 if you have libsndfile.])

    HTH :-)

Leave a Reply

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