Previous: , Up: Generalities about Autoconf tests   [Contents][Index] Default Includes

Test programs frequently need to include headers that may or may not be available on the system whose features are being tested. Each test can use all the preprocessor macros that have been AC_DEFINEd by previous tests, so for example one may write

#include <time.h>
# include <sys/time.h>

if sys/time.h has already been tested for.

All hosted environments that are still of interest for portable code provide all of the headers specified in ISO C90 (as amended in 1995): assert.h, ctype.h, errno.h, float.h, iso646.h, limits.h, locale.h, math.h, setjmp.h, signal.h, stdarg.h, stddef.h, stdio.h, stdlib.h, string.h, time.h, wchar.h, and wctype.h. Most programs can safely include these headers unconditionally. All other headers, including all headers from later revisions of the C standard, need to be tested for (see Header Files).

If your program needs to be portable to a freestanding environment, such as an embedded OS that doesn’t provide all of the facilities of the C90 standard library, you may need to test for some of the above headers as well. Note that many Autoconf macros internally assume that the complete set of C90 headers are available.

Most generic macros use the following macro to provide a default set of includes:

Macro: AC_INCLUDES_DEFAULT ([include-directives])

Expand to include-directives if present and nonempty, otherwise to:

#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
# include <sys/types.h>
# include <sys/stat.h>
# include <strings.h>
# include <inttypes.h>
# include <stdint.h>
# include <unistd.h>

Using this macro without include-directives has the side effect of checking for sys/types.h, sys/stat.h, strings.h, inttypes.h, stdint.h, and unistd.h, as if by AC_CHECK_HEADERS. For backward compatibility’s sake, it also unconditionally defines HAVE_STRING_H, HAVE_STDLIB_H, and STDC_HEADERS. New code should not make use of these preprocessor macros.


Check for all the headers that AC_INCLUDES_DEFAULT would check for as a side-effect, if this has not already happened.

This macro mainly exists so that autoupdate can replace certain obsolete constructs with it. You should not need to use it yourself; in fact, it is likely to be safe to delete it from any script in which it appears. (autoupdate does not know whether preprocessor macros such as HAVE_STDINT_H are used in the program, nor whether they would get defined as a side-effect of other checks.)

Previous: , Up: Generalities about Autoconf tests   [Contents][Index]