www.delorie.com/gnu/docs/autoconf/autoconf_28.html   search  
Buy the book!


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.8.1 Configuration Header Templates

Your distribution should contain a template file that looks as you want the final header file to look, including comments, with #undef statements which are used as hooks. For example, suppose your `configure.ac' makes these calls:


Then you could have code like the following in `conf.h.in'. On systems that have `unistd.h', configure will `#define' `HAVE_UNISTD_H' to 1. On other systems, the whole line will be commented out (in case the system predefines that symbol).

/* Define as 1 if you have unistd.h.  */

Pay attention that `#undef' is in the first column, and there is nothing behind `HAVE_UNISTD_H', not even white spaces. You can then decode the configuration header using the preprocessor directives:

#include <conf.h>

# include <unistd.h>
/* We are in trouble.  */

The use of old form templates, with `#define' instead of `#undef' is strongly discouraged. Similarly with old templates with comments on the same line as the `#undef'. Anyway, putting comments in preprocessor macros has never been a good idea.

Since it is a tedious task to keep a template header up to date, you may use autoheader to generate it, see 4.8.2 Using autoheader to Create `config.h.in'.

  webmaster   donations   bookstore     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003