【发布时间】:2015-08-26 15:19:57
【问题描述】:
在 Red Hat Linux 站上,我使用 devtoolset2 给出以下命令:
scl enable devtoolset-2 bash
然后,当我调用 gcc --version 时,我得到:
gcc (GCC) 4.8.2 20140120 (Red Hat 4.8.2-15)
Copyright (C) 2013 Free Software Foundation, Inc.
但是如果我编译我的程序(使用 cmake 生成的 malkefile,添加以下行:
if(UNIX)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++11")
endif()
我有以下错误信息:
cc1plus: error: unrecognized command line option "-std=c++11"
如果我编译用 -std=c++0x 替换 -std=c++11 然后,我得到这些消息:
nullptr wasnt declared in this scope.
考虑到它是关键字,如何无法识别 nullptr?
我不明白,如果你有任何想法......
【问题讨论】:
-
根据this
nullptr从4.6版开始支持 -
cc1plus: error: unrecognized command line option "-std=c++11" -
你确定 cmake 使用的是正确的 gcc 版本吗?
-
@C0deH4cker cc1plus 是 g++ 的编译器部分。
-
@C0deH4cker 这不是我的经验:
$ g++ q.cpp -std=asdf结果:cc1plus: error: unrecognized command line option "-std=asdf"