Up: C++ Support   [Contents][Index]

10.3.1 C++ Compiler Characteristics

Macro: AC_PROG_CXX ([compiler-search-list])

Determine a C++ compiler to use. Check whether the environment variable CXX or CCC (in that order) is set; if so, then set output variable CXX to its value.

Otherwise, if the macro is invoked without an argument, then search for a C++ compiler under the likely names (first g++ and c++ then other names). If none of those checks succeed, then as a last resort set CXX to g++.

This macro may, however, be invoked with an optional first argument which, if specified, must be a blank-separated list of C++ compilers to search for. This just gives the user an opportunity to specify an alternative search list for the C++ compiler. For example, if you didn’t like the default order, then you could invoke AC_PROG_CXX like this:

AC_PROG_CXX([gcc cl KCC CC cxx cc++ xlC aCC c++ g++])

If necessary, add an option to output variable CXX to enable support for ISO Standard C++ features with extensions. Prefer the newest C++ standard that is supported. Currently the newest standard is ISO C++11, with ISO C++98 being the previous standard. After calling this macro you can check whether the C++ compiler has been set to accept Standard C++; if not, the shell variable ac_cv_prog_cxx_stdcxx is set to ‘no’. If the C++ compiler will not accept C++11, the shell variable ac_cv_prog_cxx_cxx11 is set to ‘no’, and if it will not accept C++98, the shell variable ac_cv_prog_cxx_cxx98 is set to ‘no’.

When attempting to add compiler options, prefer extended functionality to strict conformance: the goal is to enable whatever standard features that are available, not to check for full conformance to the standard or to prohibit incompatible extensions. Test for C++11 support by checking for the language features auto, constexpr, decltype, defaulted and deleteed constructors, delegate constructors, final, initializer lists, lambda functions, nullptr, override, range-based for loops, template brackets without spaces and unicode literals, and library features std::array, std::shared_ptr, std::weak_ptr, std::regex and std::tuple. Test for C++98 support using basic features of the std namespace including std::string, containers (std::list, std::map, std::set, std::vector), streams (fstreams, iostreams, stringstreams, iomanip), std::pair, exceptions (try, catch and std::runtime_error) and algorithms. Tests for more recent standards include all the tests for older standards.

If using the GNU C++ compiler, set shell variable GXX to ‘yes’. If output variable CXXFLAGS was not already set, set it to -g -O2 for the GNU C++ compiler (-O2 on systems where G++ does not accept -g), or -g for other compilers. If your package does not like this default, then it is acceptable to insert the line ‘: ${CXXFLAGS=""}’ after AC_INIT and before AC_PROG_CXX to select an empty default instead.

Macro: AC_PROG_CXXCPP

Set output variable CXXCPP to a command that runs the C++ preprocessor. If ‘$CXX -E’ doesn’t work, /lib/cpp is used. It is portable to run CXXCPP only on files with a .c, .C, .cc, or .cpp extension.

Some preprocessors don’t indicate missing include files by the error status. For such preprocessors an internal variable is set that causes other macros to check the standard error from the preprocessor and consider the test failed if any warnings have been reported. However, it is not known whether such broken preprocessors exist for C++.

Macro: AC_PROG_CXX_C_O

Test whether the C++ compiler accepts the options -c and -o simultaneously, and define CXX_NO_MINUS_C_MINUS_O, if it does not.

Up: C++ Support   [Contents][Index]