5.6.1 Portability of Headers
This section documents some collected knowledge about common headers,
and the problems they cause. By definition, this list always requires
additions. A much more complete list is maintained by the Gnulib
project (see Gnulib), covering Posix Headers and Glibc Headers. Please help us keep
the gnulib list as complete as possible.
- limits.h
- C99 says that limits.h defines
LLONG_MIN
,
LLONG_MAX
, and ULLONG_MAX
, but many almost-C99
environments (e.g., default GCC 4.0.2 + glibc 2.4) do not
define them.
- inttypes.h vs. stdint.h
-
The C99 standard says that inttypes.h includes
stdint.h, so there's no need to include stdint.h
separately in a standard environment. Some implementations have
inttypes.h but not stdint.h (e.g., Solaris 7), but we don't
know of any implementation that has stdint.h but not
inttypes.h.
- linux/irda.h
-
It requires linux/types.h and sys/socket.h.
- linux/random.h
-
It requires linux/types.h.
- net/if.h
-
On Darwin, this file requires that sys/socket.h be included
beforehand. One should run:
AC_CHECK_HEADERS([sys/socket.h])
AC_CHECK_HEADERS([net/if.h], [], [],
[#include <stdio.h>
#ifdef STDC_HEADERS
# include <stdlib.h>
# include <stddef.h>
#else
# ifdef HAVE_STDLIB_H
# include <stdlib.h>
# endif
#endif
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
])
- netinet/if_ether.h
-
On Darwin, this file requires that stdio.h and
sys/socket.h be included beforehand. One should run:
AC_CHECK_HEADERS([sys/socket.h])
AC_CHECK_HEADERS([netinet/if_ether.h], [], [],
[#include <stdio.h>
#ifdef STDC_HEADERS
# include <stdlib.h>
# include <stddef.h>
#else
# ifdef HAVE_STDLIB_H
# include <stdlib.h>
# endif
#endif
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
])
- stdint.h
- See above, item inttypes.h vs. stdint.h.
- stdlib.h
-
On many systems (e.g., Darwin), stdio.h is a prerequisite.
- sys/mount.h
-
On FreeBSD 4.8 on ia32 and using gcc version 2.95.4,
sys/params.h is a prerequisite.
- sys/ptem.h
-
On Solaris 8, sys/stream.h is a prerequisite.
- sys/socket.h
-
On Darwin, stdlib.h is a prerequisite.
- sys/ucred.h
-
On Tru64 5.1, sys/types.h is a prerequisite.
- X11/extensions/scrnsaver.h
-
Using XFree86, this header requires X11/Xlib.h, which is probably
so required that you might not even consider looking for it.
AC_CHECK_HEADERS([X11/extensions/scrnsaver.h], [], [],
[[#include <X11/Xlib.h>
]])