2012-11-01 9 views
6

Ich schaffe es nicht verwenden zu finden, wie scons zu sagen, C++ 11-Standard zu übernehmen:Wie scons sagen, die C++ 11-Standard

die SConstruct Datei:

env=Environment(CPPPATH='/usr/include/boost/', 
       CPPDEFINES=[], 
       LIBS=[], 
       SCONS_CXX_STANDARD="c++11" 
       ) 

env.Program('Hello', Glob('src/*.cpp')) 

die CPP-Datei:

#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; 
}; 

Fehlermeldung, wenn scons Aufruf:

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. 

offensichtlich es nicht versteht, auto und nullptr

Antwort

11

Ich bin nicht sicher, ob SCONS_CXX_STANDARD noch in SCons unterstützt wird.

Stattdessen, wenn Sie GCC 4.7 oder höher verwenden, versuchen -std=c++11 an den Compiler vorbei wie folgt:

env=Environment(CPPPATH='/usr/include/boost/', 
       CPPDEFINES=[], 
       LIBS=[], 
       CXXFLAGS="-std=c++0x" 
       ) 

Wie in this question erklärt, Sie -gnu++11

+1

yep thanx benötigen. Es funktioniert gut, aber ich habe Ihre Antwort korrigiert: das echte g ++ Flag ist -std = C++ 0x, nicht -std = C++ 11 –

+0

@StephaneRolland, ok danke – Brady

+0

Ja, SCONS ist kein Compiler und keine Anweisungen wie CXX_STANDART . Es ist nur Compiler-Flag. – Torsten