Next: , Previous: Running the Preprocessor, Up: Writing Tests

6.4 Running the Compiler

To check for a syntax feature of the current language's (see Language Choice) compiler, such as whether it recognizes a certain keyword, or simply to try some library feature, use AC_COMPILE_IFELSE to try to compile a small program that uses that feature.

— Macro: AC_COMPILE_IFELSE (input, [action-if-true], [action-if-false])

Run the compiler and compilation flags of the current language (see 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.

It is customary to report unexpected failures with AC_MSG_FAILURE. This macro does not try to link; use AC_LINK_IFELSE if you need to do that (see Running the Linker). If needed, action-if-true can further access the just-compiled object file conftest.$OBJEXT.

This macro uses AC_REQUIRE for the compiler associated with the current language, which means that if the compiler has not yet been determined, the compiler determination will be made prior to the body of the outermust AC_DEFUN macro that triggered this macro to expand (see Expanded Before Required).

For tests in Erlang, the input must be the source code of a module named conftest. AC_COMPILE_IFELSE generates a conftest.beam file that can be interpreted by the Erlang virtual machine (ERL). It is recommended to use AC_LANG_PROGRAM to specify the test program, to ensure that the Erlang module has the right name.