6
我不設法找到如何告訴scons的接受C++的11個標準:如何告訴scons的使用C++ 11標準
的SConstruct文件:
env=Environment(CPPPATH='/usr/include/boost/',
CPPDEFINES=[],
LIBS=[],
SCONS_CXX_STANDARD="c++11"
)
env.Program('Hello', Glob('src/*.cpp'))
cpp文件:調用scons的時候
#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: 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
和nullptr
是的感謝名單。它工作正常,但我糾正了你的答案:真正的g ++標誌是-std = C++ 0x,而不是-std = C++ 11 –
@StephaneRolland,好的謝謝 – Brady
是的,scons不是編譯器,不支持像CXX_STANDART 。這只是編譯器標誌。 – Torsten