Previous: Particular Declarations, Up: Declarations
These macros are used to find declarations not covered by the “particular” test macros.
If symbol (a function, variable, or constant) is not declared in includes and a declaration is needed, run the shell commands action-if-not-found, otherwise action-if-found. includes is a series of include directives, defaulting to
AC_INCLUDES_DEFAULT
(see Default Includes), which are used prior to the declaration under test.This macro actually tests whether symbol is defined as a macro or can be used as an r-value, not whether it is really declared, because it is much safer to avoid introducing extra declarations when they are not needed.
For each of the symbols (comma-separated list), define
HAVE_DECL_
symbol (in all capitals) to `1' if symbol is declared, otherwise to `0'. If action-if-not-found is given, it is additional shell code to execute when one of the function declarations is needed, otherwise action-if-found is executed.includes is a series of include directives, defaulting to
AC_INCLUDES_DEFAULT
(see Default Includes), which are used prior to the declarations under test.This macro uses an M4 list as first argument:
AC_CHECK_DECLS([strdup]) AC_CHECK_DECLS([strlen]) AC_CHECK_DECLS([malloc, realloc, calloc, free]) AC_CHECK_DECLS([j0], [], [], [[#include <math.h>]])Unlike the other `AC_CHECK_*S' macros, when a symbol is not declared,
HAVE_DECL_
symbol is defined to `0' instead of leavingHAVE_DECL_
symbol undeclared. When you are sure that the check was performed, useHAVE_DECL_
symbol in#if
:#if !HAVE_DECL_SYMBOL extern char *symbol; #endifIf the test may have not been performed, however, because it is safer not to declare a symbol than to use a declaration that conflicts with the system's one, you should use:
#if defined HAVE_DECL_MALLOC && !HAVE_DECL_MALLOC void *malloc (size_t *s); #endifYou fall into the second category only in extreme situations: either your files may be used without being configured, or they are used during the configuration. In most cases the traditional approach is enough.
For each of the symbols (comma-separated list), define
HAVE_DECL_
symbol (in all capitals) to `1' if symbol is declared in the default include files, otherwise to `0'. This is a once-only variant ofAC_CHECK_DECLS
. It generates the checking code at most once, so that configure is smaller and faster; but the checks cannot be conditionalized and are always done once, early during the configure run.