Validating Autotools in C ++ 11

I use AX_CXX_COMPILE_STDCXX_0X (can be found in the autoconf archive) to test the capabilities of the C ++ 11 compiler. It correctly determines that -std=c++0x is required, but does not add it to CXXFLAGS . I looked at the source of the macro and it checks, but then restores the previous flags.

What should I do to set CXXFLAGS ability to compile a C ++ 11 source?

Just adding -std=c++0x to AM_CXXFLAGS not a good solution because I would like to take responsibility for the compiler compiling in C ++ 11 from autoconf developers, not mine.

+21
c ++ c ++ 11 autotools autoconf
Aug 10 2018-12-21T00:
source share
2 answers

What you are looking for has already been done as AX_CXX_COMPILE_STDCXX_11 , part of the autoconf-archive . It will add the required option to the environment (previously through CXXFLAGS , now through CXX ) and an error if support for C ++ 11 is not available.

+28
Aug 10 2018-12-12T00:
source share
— -

In general, you can compile simple code and set a variable based on your compilation results.

 DIALECT="-std=c++14" echo 'int main() {return 0;}' > ./log.cpp && $CXX -std=c++14 ./log.cpp || $DIALECT="no" if test $DILAECT = no; then AC_MSG_ERROR([c++ compiler does not support c++14]) else echo $DILAECT fi 
+1
Mar 27 '18 at 16:56
source share



All Articles