如何告诉SCONS使用C 11标准
How to tell scons to use the C++11 standard
我没有设法找到如何告诉SCONS接受C 11标准:
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时错误消息:
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中是否支持SCONS_CXX_STANDARD
。
相反,如果您使用的是GCC 4.7或更高版本,请尝试将-std=c++11
传递给编译器,如下所示:
env=Environment(CPPPATH='/usr/include/boost/',
CPPDEFINES=[],
LIBS=[],
CXXFLAGS="-std=c++0x"
)
如这个问题所述,您可能需要-gnu++11
相关文章:
- 使用CMake检测支持的C++标准
- 标准是否使用多余的大括号(例如 T{{{10}}})定义列表初始化?
- 编译器如何在使用SFINAE的函数和标准函数之间确定两者是否可行
- 捕获标准输出以压缩并使用 CTRL-C 中断会给出损坏的 zip 文件
- 如何在 Mac 上使用 c++17 并行标准库算法?
- 标准::向量声明中使用的模板参数
- 使用带有C++对象和标准库容器的插件系统
- 是否允许使用带有"w+"模式的 freopen 进行标准设置?
- 如何使用模板化标准::函数作为参数?
- 初学者如何使用标准::any_of?
- C4204:使用的非标准扩展:非常量聚合初始值设定项
- 使用宏编译时使用用户定义的数学函数,或者仅使用 c++ 中标准数学库中的函数
- 标准::enable_if和通用参考的使用差异
- 如何将来自 Boost.Python 的map_indexing_suite与自定义而不是标准对象一起使用?
- 使用提升过程获取 shell 命令的标准输出
- 使用标准库计算字符串中的十进制数
- Visual Studio 如何在内核模式驱动程序项目中使用C++标准库?
- 使用 lambda 表达式的 Raspbian G++ 8.3.0 导致 ']' 之前的预期主表达式 - 即使标准设置为 c++14
- 没有 Emscripten,如何使用标准库编译C++到 WebAssembly
- 使用库时的标准 - 使用库的数据类型 VS 创建我自己的类型?