我无法找到如何告诉 scons 接受 c++11 标准:
SConstruct 文件:
env=Environment(CPPPATH='/usr/include/boost/',
CPPDEFINES=[],
LIBS=[],
SCONS_CXX_STANDARD="c++11"
)
env.Program('Hello', Glob('src/*.cpp'))
.cpp 文件:
#include <iostream>
class A{};
int main()
{
std::cout << "hello world!" << std::endl;
auto test = new A; // testing auto C++11 keyword
if( test == nullptr ){std::cout << "hey hey" << std::endl;} // testing nullptr keyword
else{std::cout << " the pointer is not null" << std::endl;}
return 0;
};
调用scons时出现错误信息:
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
g++ -o src/hello_world.o -c -I/usr/include/boost src/hello_world.cpp
src/hello_world.cpp: In function 'int main()':
src/hello_world.cpp:13:8: error: 'test' does not name a type
src/hello_world.cpp:15:7: error: 'test' was not declared in this scope
src/hello_world.cpp:15:15: error: 'nullptr' was not declared in this scope
scons: *** [src/hello_world.o] Error 1
scons: building terminated because of errors.
显然它不明白auto
and nullptr
我不确定是否SCONS_CXX_STANDARD
SCons 中尚受支持。
相反,如果您使用的是 GCC 4.7 或更高版本,请尝试传递-std=c++11
给编译器如下:
env=Environment(CPPPATH='/usr/include/boost/',
CPPDEFINES=[],
LIBS=[],
CXXFLAGS="-std=c++0x"
)
正如中所解释的这个问题 https://stackoverflow.com/q/10613126/1158895, 你可能需要-gnu++11
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)