autoconf: Present But Cannot Be Compiled
1
1 20.7 Header Present But Cannot Be Compiled
1 ==========================================
1
1 The most important guideline to bear in mind when checking for features
1 is to mimic as much as possible the intended use. Unfortunately, old
1 versions of `AC_CHECK_HEADER' and `AC_CHECK_HEADERS' failed to follow
1 this idea, and called the preprocessor, instead of the compiler, to
1 check for headers. As a result, incompatibilities between headers went
1 unnoticed during configuration, and maintainers finally had to deal
1 with this issue elsewhere.
1
1 The transition began with Autoconf 2.56. As of Autoconf 2.64 both
1 checks are performed, and `configure' complains loudly if the compiler
1 and the preprocessor do not agree. However, only the compiler result
1 is considered.
1
1 Consider the following example:
1
1 $ cat number.h
1 typedef int number;
1 $ cat pi.h
1 const number pi = 3;
1 $ cat configure.ac
1 AC_INIT([Example], [1.0], [bug-example@example.org])
1 AC_CHECK_HEADERS([pi.h])
1 $ autoconf -Wall
1 $ ./configure
1 checking for gcc... gcc
1 checking for C compiler default output file name... a.out
1 checking whether the C compiler works... yes
1 checking whether we are cross compiling... no
1 checking for suffix of executables...
1 checking for suffix of object files... o
1 checking whether we are using the GNU C compiler... yes
1 checking whether gcc accepts -g... yes
1 checking for gcc option to accept ISO C89... none needed
1 checking how to run the C preprocessor... gcc -E
1 checking for grep that handles long lines and -e... grep
1 checking for egrep... grep -E
1 checking for ANSI C header files... yes
1 checking for sys/types.h... yes
1 checking for sys/stat.h... yes
1 checking for stdlib.h... yes
1 checking for string.h... yes
1 checking for memory.h... yes
1 checking for strings.h... yes
1 checking for inttypes.h... yes
1 checking for stdint.h... yes
1 checking for unistd.h... yes
1 checking pi.h usability... no
1 checking pi.h presence... yes
1 configure: WARNING: pi.h: present but cannot be compiled
1 configure: WARNING: pi.h: check for missing prerequisite headers?
1 configure: WARNING: pi.h: see the Autoconf documentation
1 configure: WARNING: pi.h: section "Present But Cannot Be Compiled"
1 configure: WARNING: pi.h: proceeding with the compiler's result
1 configure: WARNING: ## -------------------------------------- ##
1 configure: WARNING: ## Report this to bug-example@example.org ##
1 configure: WARNING: ## -------------------------------------- ##
1 checking for pi.h... yes
1
1 Generic Headers::):
1
1 $ cat configure.ac
1 AC_INIT([Example], [1.0], [bug-example@example.org])
1 AC_CHECK_HEADERS([number.h pi.h], [], [],
1 [[#ifdef HAVE_NUMBER_H
1 # include <number.h>
1 #endif
1 ]])
1 $ autoconf -Wall
1 $ ./configure
1 checking for gcc... gcc
1 checking for C compiler default output... a.out
1 checking whether the C compiler works... yes
1 checking whether we are cross compiling... no
1 checking for suffix of executables...
1 checking for suffix of object files... o
1 checking whether we are using the GNU C compiler... yes
1 checking whether gcc accepts -g... yes
1 checking for gcc option to accept ANSI C... none needed
1 checking for number.h... yes
1 checking for pi.h... yes
1
1 See ⇒Particular Headers, for a list of headers with their
1 prerequisites.
1