0
点赞
收藏
分享

微信扫一扫

在CMake中使用C++11 (解决 ‘nullptr‘ was not declared in this scope)


'nullptr' was not declared in this scope  问题是编译器没有开启C++11特性。 

如果直接使用gcc/g++, 在 gcc /g++参数中添加 -std=c11  /  -std=c++11

即:

g++ -g -Wall -std=c++11 main.cpp

gcc -g -Wall -std=c11 main.cpp

注意: 需要更新gcc/g++版本。 5以上应该就可以。

若在CMake中遇到该nullptr问题:

要在CMake中使用C++11,只要在CMakeLists.txt中添加一行:

add_definitions(-std=c++11)

OR

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")

了解更多关于《计算机视觉与图形学》相关知识,请关注公众号:

在CMake中使用C++11 (解决 ‘nullptr‘ was not declared in this scope)_g++

下载我们视频中代码和相关讲义,请在公众号回复:计算机视觉课程资料

举报

相关推荐

0 条评论