autoconf: Default Includes

1 
1 5.1.2 Default Includes
1 ----------------------
1 
1 Several tests depend upon a set of header files.  Since these headers
1 are not universally available, tests actually have to provide a set of
1 protected includes, such as:
1 
1      #ifdef TIME_WITH_SYS_TIME
1      # include <sys/time.h>
1      # include <time.h>
1      #else
1      # ifdef HAVE_SYS_TIME_H
1      #  include <sys/time.h>
1      # else
1      #  include <time.h>
1      # endif
1      #endif
1 
1 Unless you know exactly what you are doing, you should avoid using
1 unconditional includes, and check the existence of the headers you
1 include beforehand (⇒Header Files).
1 
1    Most generic macros use the following macro to provide the default
1 set of includes:
1 
1  -- Macro: AC_INCLUDES_DEFAULT ([INCLUDE-DIRECTIVES])
1      Expand to INCLUDE-DIRECTIVES if defined, otherwise to:
1 
1           #include <stdio.h>
1           #ifdef HAVE_SYS_TYPES_H
1           # include <sys/types.h>
1           #endif
1           #ifdef HAVE_SYS_STAT_H
1           # include <sys/stat.h>
1           #endif
1           #ifdef STDC_HEADERS
1           # include <stdlib.h>
1           # include <stddef.h>
1           #else
1           # ifdef HAVE_STDLIB_H
1           #  include <stdlib.h>
1           # endif
1           #endif
1           #ifdef HAVE_STRING_H
1           # if !defined STDC_HEADERS && defined HAVE_MEMORY_H
1           #  include <memory.h>
1           # endif
1           # include <string.h>
1           #endif
1           #ifdef HAVE_STRINGS_H
1           # include <strings.h>
1           #endif
1           #ifdef HAVE_INTTYPES_H
1           # include <inttypes.h>
1           #endif
1           #ifdef HAVE_STDINT_H
1           # include <stdint.h>
1           #endif
1           #ifdef HAVE_UNISTD_H
1           # include <unistd.h>
1           #endif
1 
1      If the default includes are used, then check for the presence of
1      these headers and their compatibility, i.e., you don't need to run
1      `AC_HEADER_STDC', nor check for `stdlib.h' etc.
1 
1      These headers are checked for in the same order as they are
1      included.  For instance, on some systems `string.h' and
1      `strings.h' both exist, but conflict.  Then `HAVE_STRING_H' is
1      defined, not `HAVE_STRINGS_H'.
1