GNU Info

Info Node: (autoconf.info)Defining Symbols

(autoconf.info)Defining Symbols


Next: Setting Output Variables Up: Results
Enter node , (file) or (file)node

Defining C Preprocessor Symbols
===============================

   A common action to take in response to a feature test is to define a
C preprocessor symbol indicating the results of the test.  That is done
by calling `AC_DEFINE' or `AC_DEFINE_UNQUOTED'.

   By default, `AC_OUTPUT' places the symbols defined by these macros
into the output variable `DEFS', which contains an option
`-DSYMBOL=VALUE' for each symbol defined.  Unlike in Autoconf version
1, there is no variable `DEFS' defined while `configure' is running.
To check whether Autoconf macros have already defined a certain C
preprocessor symbol, test the value of the appropriate cache variable,
as in this example:

     AC_CHECK_FUNC(vprintf, [AC_DEFINE(HAVE_VPRINTF)])
     if test "$ac_cv_func_vprintf" != yes; then
       AC_CHECK_FUNC(_doprnt, [AC_DEFINE(HAVE_DOPRNT)])
     fi

   If `AC_CONFIG_HEADERS' has been called, then instead of creating
`DEFS', `AC_OUTPUT' creates a header file by substituting the correct
values into `#define' statements in a template file.  Note:
Configuration Headers, for more information about this kind of output.

 - Macro: AC_DEFINE (VARIABLE, [VALUE], [DESCRIPTION])
     Define C preprocessor variable VARIABLE.  If VALUE is given, set
     VARIABLE to that value (verbatim), otherwise set it to 1.  VALUE
     should not contain literal newlines, and if you are not using
     `AC_CONFIG_HEADERS' it should not contain any `#' characters, as
     `make' tends to eat them.  To use a shell variable (which you need
     to do in order to define a value containing the M4 quote
     characters `[' or `]'), use `AC_DEFINE_UNQUOTED' instead.
     DESCRIPTION is only useful if you are using `AC_CONFIG_HEADERS'.
     In this case, DESCRIPTION is put into the generated `config.h.in'
     as the comment before the macro define.  The following example
     defines the C preprocessor variable `EQUATION' to be the string
     constant `"$a > $b"':

          AC_DEFINE(EQUATION, "$a > $b")

 - Macro: AC_DEFINE_UNQUOTED (VARIABLE, [VALUE], [DESCRIPTION])
     Like `AC_DEFINE', but three shell expansions are
     performed--once--on VARIABLE and VALUE: variable expansion (`$'),
     command substitution (``'), and backslash escaping (`\').  Single
     and double quote characters in the value have no special meaning.
     Use this macro instead of `AC_DEFINE' when VARIABLE or VALUE is a
     shell variable.  Examples:

          AC_DEFINE_UNQUOTED(config_machfile, "$machfile")
          AC_DEFINE_UNQUOTED(GETGROUPS_T, $ac_cv_type_getgroups)
          AC_DEFINE_UNQUOTED($ac_tr_hdr)

   Due to the syntactical bizarreness of the Bourne shell, do not use
semicolons to separate `AC_DEFINE' or `AC_DEFINE_UNQUOTED' calls from
other macro calls or shell code; that can cause syntax errors in the
resulting `configure' script.  Use either spaces or newlines.  That is,
do this:

     AC_CHECK_HEADER(elf.h, [AC_DEFINE(SVR4) LIBS="$LIBS -lelf"])

or this:

     AC_CHECK_HEADER(elf.h,
      [AC_DEFINE(SVR4)
       LIBS="$LIBS -lelf"])

instead of this:

     AC_CHECK_HEADER(elf.h, [AC_DEFINE(SVR4); LIBS="$LIBS -lelf"])


automatically generated by info2www version 1.2.2.9