File: autoconf.info, Node: Default Includes, Prev: Standard Symbols, Up: Common Behavior 5.1.2 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_DEFINE’d by previous tests, so for example one may write #include#ifdef HAVE_SYS_TIME_H # include #endif 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 C89 (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. A program not intended to be portable to C89 can also safely include the C99-specified header ‘stdbool.h’. Other headers, including headers from C99 and later revisions of the C standard, might need to be tested for (*note Header Files::) or their bugs may need to be worked around (*note Gnulib::). 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 C89 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 C89 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 #ifdef HAVE_STDIO_H # include #endif #ifdef HAVE_STDLIB_H # include #endif #ifdef HAVE_STRING_H # include #endif #ifdef HAVE_INTTYPES_H # include #endif #ifdef HAVE_STDINT_H # include #endif #ifdef HAVE_STRINGS_H # include #endif #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SYS_STAT_H # include #endif #ifdef HAVE_UNISTD_H # include #endif Using this macro without INCLUDE-DIRECTIVES has the side effect of checking for ‘stdio.h’, ‘stdlib.h’, ‘string.h’, ‘inttypes.h’, ‘stdint.h’, ‘strings.h’, ‘sys/types.h’, ‘sys/stat.h’, and ‘unistd.h’, as if by ‘AC_CHECK_HEADERS_ONCE’. For backward compatibility, the macro ‘STDC_HEADERS’ will be defined when both ‘stdlib.h’ and ‘string.h’ are available. *Portability Note:* It is safe for most programs to assume the presence of all of the headers required by the original 1990 C standard. ‘AC_INCLUDES_DEFAULT’ checks for ‘stdio.h’, ‘stdlib.h’, and ‘string.h’, even though they are in that list, because they might not be available when compiling for a "freestanding environment" (in which most of the features of the C library are optional). You probably do not need to write ‘#ifdef HAVE_STDIO_H’ in your own code. ‘inttypes.h’ and ‘stdint.h’ were added to C in the 1999 revision of the standard, and ‘strings.h’, ‘sys/types.h’, ‘sys/stat.h’, and ‘unistd.h’ are POSIX extensions. You _should_ guard uses of these headers with appropriate conditionals. -- Macro: AC_CHECK_INCLUDES_DEFAULT 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.)