如何告诉scons使用C ++ 11标准 [英] How to tell scons to use the C++11 standard

查看:240
本文介绍了如何告诉scons使用C ++ 11标准的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法找到如何告诉scons接受c ++ 11标准:

I don't manage to find how to tell scons to accept c++11 standard:

SConstruct文件 p>

the SConstruct file:

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: 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

推荐答案

我不知道 SCONS_CXX_STANDARD

Im not sure if SCONS_CXX_STANDARD is supported yet in SCons.

如果您使用的是GCC 4.7或更高版本,请尝试传递 -std = c ++ 11 到编译器,如下:

Instead, if you're using GCC 4.7 or later, try passing -std=c++11 to the compiler as follows:

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

此问题中所述,您可能需要 -gnu ++ 11

这篇关于如何告诉scons使用C ++ 11标准的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆