Marko Lindqvist <cazfi74@xxxxxxxxx> writes: > On 14 September 2012 02:43, Eric Blake <eblake@xxxxxxxxxx> wrote: >> On 09/13/2012 05:22 PM, Kip Warner wrote: >>> Why do many autoconfiscated projects bracket inclusion of the >>> generated config.h with #if HAVE_CONFIG_H / #endif. >> >> Bad copy-and-paste habits. > I've seen some packages where same sources are used with multiple build > systems (typically autotools in more unixy systems and visual studio > project files on Windows) and it's actually needed to weed out > "config.h" include when building with system that does not provide it. > But more often "#ifdef HAVE_CONFIG_H" is just idiom copied from some > other project. I believe the #ifdef wrapper used to be recommended by the Autoconf manual way back, many moons ago (2.13 days at the latest), because it was how the transition from defining things via -D on the command line to using a header was handled. It goes along with the definition of @DEFS@, which previously (and by previously I mean a long time ago) used to contain all the results of configure as -D flags to the compiler, but which was replaced by just "-DHAVE_CONFIG_H" if you used the AC_CONFIG_HEADERS (or its earlier versions) macro. So, in other words, you could transition your package that was assuming -D flags on the compiler command line to using a config.h header by adding that #ifdef code to the source files, and then it would work with either Autoconf method: either a config.h file or direct -D flags on the compiler command line. I suspect the above is what's happening when you see this in really old projects, and in newer projects it's copy and paste from older projects. -- Russ Allbery (rra@xxxxxxxxxxxx) <http://www.eyrie.org/~eagle/> _______________________________________________ Autoconf mailing list Autoconf@xxxxxxx https://lists.gnu.org/mailman/listinfo/autoconf