Autotools check for C++11

喜夏-厌秋 提交于 2019-11-28 08:11:57

What you're looking for has already been made as AX_CXX_COMPILE_STDCXX_11, part of autoconf-archive. It will add the required option to the environment (formerly through CXXFLAGS, now through CXX) and error out if no C++11 support is available.

In general you can compile a simple code and set a variable based the outcome of your compilation

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
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!