autoconf: Generic Declarations
1
1 5.7.2 Generic Declaration Checks
1 --------------------------------
1
1 These macros are used to find declarations not covered by the
1 "particular" test macros.
1
1 -- Macro: AC_CHECK_DECL (SYMBOL, [ACTION-IF-FOUND],
1 [ACTION-IF-NOT-FOUND], [INCLUDES = `AC_INCLUDES_DEFAULT'])
1 If SYMBOL (a function, variable, or constant) is not declared in
1 INCLUDES and a declaration is needed, run the shell commands
1 ACTION-IF-NOT-FOUND, otherwise ACTION-IF-FOUND. INCLUDES is a
1 series of include directives, defaulting to `AC_INCLUDES_DEFAULT'
1 (⇒Default Includes), which are used prior to the
1 declaration under test.
1
1 This macro actually tests whether SYMBOL is defined as a macro or
1 can be used as an r-value, not whether it is really declared,
1 because it is much safer to avoid introducing extra declarations
1 when they are not needed. In order to facilitate use of C++ and
1 overloaded function declarations, it is possible to specify
1 function argument types in parentheses for types which can be
1 zero-initialized:
1
1 AC_CHECK_DECL([basename(char *)])
1
1 This macro caches its result in the `ac_cv_have_decl_SYMBOL'
1 variable, with characters not suitable for a variable name mapped
1 to underscores.
1
1 -- Macro: AC_CHECK_DECLS (SYMBOLS, [ACTION-IF-FOUND],
1 [ACTION-IF-NOT-FOUND], [INCLUDES = `AC_INCLUDES_DEFAULT'])
1 For each of the SYMBOLS (_comma_-separated list with optional
1 function argument types for C++ overloads), define
1 `HAVE_DECL_SYMBOL' (in all capitals) to `1' if SYMBOL is declared,
1 otherwise to `0'. If ACTION-IF-NOT-FOUND is given, it is
1 additional shell code to execute when one of the function
1 declarations is needed, otherwise ACTION-IF-FOUND is executed.
1
1 INCLUDES is a series of include directives, defaulting to
1 `AC_INCLUDES_DEFAULT' (⇒Default Includes), which are used
1 prior to the declarations under test.
1
1 This macro uses an M4 list as first argument:
1 AC_CHECK_DECLS([strdup])
1 AC_CHECK_DECLS([strlen])
1 AC_CHECK_DECLS([malloc, realloc, calloc, free])
1 AC_CHECK_DECLS([j0], [], [], [[#include <math.h>]])
1 AC_CHECK_DECLS([[basename(char *)], [dirname(char *)]])
1
1 Unlike the other `AC_CHECK_*S' macros, when a SYMBOL is not
1 declared, `HAVE_DECL_SYMBOL' is defined to `0' instead of leaving
1 `HAVE_DECL_SYMBOL' undeclared. When you are _sure_ that the check
1 was performed, use `HAVE_DECL_SYMBOL' in `#if':
1
1 #if !HAVE_DECL_SYMBOL
1 extern char *symbol;
1 #endif
1
1 If the test may have not been performed, however, because it is
1 safer _not_ to declare a symbol than to use a declaration that
1 conflicts with the system's one, you should use:
1
1 #if defined HAVE_DECL_MALLOC && !HAVE_DECL_MALLOC
1 void *malloc (size_t *s);
1 #endif
1
1 You fall into the second category only in extreme situations:
1 either your files may be used without being configured, or they
1 are used during the configuration. In most cases the traditional
1 approach is enough.
1
1 This macro caches its results in `ac_cv_have_decl_SYMBOL'
1 variables, with characters not suitable for a variable name mapped
1 to underscores.
1
1 -- Macro: AC_CHECK_DECLS_ONCE (SYMBOLS)
1 For each of the SYMBOLS (_comma_-separated list), define
1 `HAVE_DECL_SYMBOL' (in all capitals) to `1' if SYMBOL is declared
1 in the default include files, otherwise to `0'. This is a
1 once-only variant of `AC_CHECK_DECLS'. It generates the checking
1 code at most once, so that `configure' is smaller and faster; but
1 the checks cannot be conditionalized and are always done once,
1 early during the `configure' run.
1