(autoconf.info)Running the Preprocessor
Next: Running the Compiler Prev: Writing Test Programs Up: Writing Tests
6.3 Running the Preprocessor
Sometimes one might need to run the preprocessor on some source file.
_Usually it is a bad idea_, as you typically need to _compile_ your
project, not merely run the preprocessor on it; therefore you certainly
want to run the compiler, not the preprocessor. Resist the temptation
of following the easiest path.
Nevertheless, if you need to run the preprocessor, then use
The macros described in this section cannot be used for tests in
Erlang or Fortran, since those languages require no preprocessor.
-- Macro: AC_PREPROC_IFELSE (INPUT, [ACTION-IF-TRUE],
Run the preprocessor of the current language (Note: Language
Choice) on the INPUT, run the shell commands ACTION-IF-TRUE on
success, ACTION-IF-FALSE otherwise. The INPUT can be made by
`AC_LANG_PROGRAM' and friends.
This macro uses `CPPFLAGS', but not `CFLAGS', because `-g', `-O',
etc. are not valid options to many C preprocessors.
It is customary to report unexpected failures with
AC_INIT([Hello], [1.0], [firstname.lastname@example.org])
AC_DEFINE([HELLO_WORLD], ["Hello, World\n"],
[AC_LANG_PROGRAM([[const char hw = "Hello, World\n";]],
[[fputs (hw, stdout);]])],
[AC_MSG_FAILURE([unexpected preprocessor failure])])
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -E
The macro `AC_TRY_CPP' (Note: Obsolete Macros) used to play the
role of `AC_PREPROC_IFELSE', but double quotes its argument, making it
impossible to use it to elaborate sources. You are encouraged to get
rid of your old use of the macro `AC_TRY_CPP' in favor of
`AC_PREPROC_IFELSE', but, in the first place, are you sure you need to
run the _preprocessor_ and not the compiler?
-- Macro: AC_EGREP_HEADER (PATTERN, HEADER-FILE, ACTION-IF-FOUND,
If the output of running the preprocessor on the system header file
HEADER-FILE matches the extended regular expression PATTERN,
execute shell commands ACTION-IF-FOUND, otherwise execute
-- Macro: AC_EGREP_CPP (PATTERN, PROGRAM, [ACTION-IF-FOUND],
PROGRAM is the text of a C or C++ program, on which shell
variable, back quote, and backslash substitutions are performed.
If the output of running the preprocessor on PROGRAM matches the
extended regular expression PATTERN, execute shell commands
ACTION-IF-FOUND, otherwise execute ACTION-IF-NOT-FOUND.
automatically generated by info2www