Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Mail Systems
Eclipse Documentation

How To Guides
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Problem Solutions
Privacy Policy




6.1 Language Choice

Autoconf-generated configure scripts check for the C compiler and its features by default. Packages that use other programming languages (maybe more than one, e.g., C and C++) need to test features of the compilers for the respective languages. The following macros determine which programming language is used in the subsequent tests in

— Macro: AC_LANG (language)

Do compilation tests using the compiler, preprocessor, and file extensions for the specified language.

Supported languages are:

Do compilation tests using CC and CPP and use extension .c for test programs. Use compilation flags: CPPFLAGS with CPP, and both CPPFLAGS and CFLAGS with CC.
Do compilation tests using CXX and CXXCPP and use extension .C for test programs. Use compilation flags: CPPFLAGS with CXXPP, and both CPPFLAGS and CXXFLAGS with CXX.
Fortran 77
Do compilation tests using F77 and use extension .f for test programs. Use compilation flags: FFLAGS.
Do compilation tests using FC and use extension .f (or whatever has been set by AC_FC_SRCEXT) for test programs. Use compilation flags: FCFLAGS.
Compile and execute tests using ERLC and ERL and use extension .erl for test Erlang modules. Use compilation flags: ERLCFLAGS.
Objective C
Do compilation tests using OBJC and OBJCCPP and use extension .m for test programs. Use compilation flags: CPPFLAGS with OBJCPP, and both CPPFLAGS and OBJCFLAGS with OBJC.

— Macro: AC_LANG_PUSH (language)

Remember the current language (as set by AC_LANG) on a stack, and then select the language. Use this macro and AC_LANG_POP in macros that need to temporarily switch to a particular language.

— Macro: AC_LANG_POP ([language])

Select the language that is saved on the top of the stack, as set by AC_LANG_PUSH, and remove it from the stack.

If given, language specifies the language we just quit. It is a good idea to specify it when it's known (which should be the case...), since Autoconf detects inconsistencies.

          AC_LANG_PUSH([Fortran 77])
          # Perform some tests on Fortran 77.
          # ...
          AC_LANG_POP([Fortran 77])
— Macro: AC_LANG_ASSERT (language)

Check statically that the current language is language. You should use this in your language specific macros to avoid that they be called with an inappropriate language.

This macro runs only at autoconf time, and incurs no cost at configure time. Sadly enough and because Autoconf is a two layer language 2, the macros AC_LANG_PUSH and AC_LANG_POP cannot be “optimizing”, therefore as much as possible you ought to avoid using them to wrap your code, rather, require from the user to run the macro with a correct current language, and check it with AC_LANG_ASSERT. And anyway, that may help the user understand she is running a Fortran macro while expecting a result about her Fortran 77 compiler...


Ensure that whichever preprocessor would currently be used for tests has been found. Calls AC_REQUIRE (see Prerequisite Macros) with an argument of either AC_PROG_CPP or AC_PROG_CXXCPP, depending on which language is current.

  Published under the terms of the GNU General Public License Design by Interspire