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


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

5.6.3 Generic Header Checks

These macros are used to find system header files not covered by the "particular" test macros. If you need to check the contents of a header as well as find out whether it is present, you have to write your own test for it (see section 6. Writing Tests).

Macro: AC_CHECK_HEADER (header-file, [action-if-found], [action-if-not-found], [includes = `default-includes'])
If the system header file header-file is compilable, execute shell commands action-if-found, otherwise execute action-if-not-found. If you just want to define a symbol if the header file is available, consider using AC_CHECK_HEADERS instead.

For compatibility issues with older versions of Autoconf, please read below.

Macro: AC_CHECK_HEADERS (header-file..., [action-if-found], [action-if-not-found], [includes = `default-includes'])
For each given system header file header-file in the whitespace-separated argument list that exists, define HAVE_header-file (in all capitals). If action-if-found is given, it is additional shell code to execute when one of the header files is found. You can give it a value of `break' to break out of the loop on the first match. If action-if-not-found is given, it is executed when one of the header files is not found.

For compatibility issues with older versions of Autoconf, please read below.

Previous versions of Autoconf merely checked whether the header was accepted by the preprocessor. This was changed because the old test was inappropriate for typical uses. Headers are typically used to compile, not merely to preprocess, and the old behavior sometimes accepted headers that clashed at compile-time. If you need to check whether a header is preprocessable, you can use AC_PREPROC_IFELSE (see section 6.3 Running the Preprocessor).

This scheme, which improves the robustness of the test, also requires that you make sure that headers that must be included before the header-file be part of the includes, (see section 5.1.2 Default Includes). If looking for `bar.h', which requires that `foo.h' be included before if it exists, we suggest the following scheme:

@verbatim AC_CHECK_HEADERS([foo.h]) AC_CHECK_HEADERS([bar.h], [], [], [#if HAVE_FOO_H # include <foo.h> # endif ])

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

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