Previous: Standard Symbols, Up: Generalities about Autoconf tests [Contents][Index]
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 <time.h> #ifdef HAVE_SYS_TIME_H # include <sys/time.h> #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 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:
Expand to include-directives if present and nonempty, otherwise to:
#include <stddef.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #ifdef HAVE_SYS_TYPES_H # include <sys/types.h> #endif #ifdef HAVE_SYS_STAT_H # include <sys/stat.h> #endif #ifdef HAVE_STRINGS_H # include <strings.h> #endif #ifdef HAVE_INTTYPES_H # include <inttypes.h> #endif #ifdef HAVE_STDINT_H # include <stdint.h> #endif #ifdef HAVE_UNISTD_H # include <unistd.h> #endif
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: Standard Symbols, Up: Generalities about Autoconf tests [Contents][Index]