Next: , Up: Header Files


5.6.1 Portability of Headers

This section tries to collect knowledge about common headers, and the problems they cause. By definition, this list will always require additions. Please help us keeping it as complete as possible.

inttypes.h vs. stdint.h
Paul Eggert notes that: ISO C 1999 says that inttypes.h includes stdint.h, so there's no need to include stdint.h separately in a standard environment. Many implementations have inttypes.h but not stdint.h (e.g., Solaris 7), but I don't know of any implementation that has stdint.h but not inttypes.h. Nor do I know of any free software that includes stdint.h; stdint.h seems to be a creation of the committee.
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>
          #if STDC_HEADERS
          # include <stdlib.h>
          # include <stddef.h>
          #else
          # if HAVE_STDLIB_H
          #  include <stdlib.h>
          # endif
          #endif
          #if 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>
          #if STDC_HEADERS
          # include <stdlib.h>
          # include <stddef.h>
          #else
          # if HAVE_STDLIB_H
          #  include <stdlib.h>
          # endif
          #endif
          #if 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/socket.h
On Darwin, stdlib.h is a prerequisite.
sys/ucred.h
On HP 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>
          ]])