Build project by CMake, has a problem for use of "undeclared identifier 'nullptr' "

Viewed 1265

My project use CMake build android-ndk,when I run app to phone,that will appear use of undeclared identifier 'nullptr'

The code is build, for log :

/Users/userName/Desktop/GuideMachine/SDK-Android/app/src/main/cpp/ivw-jni/ivw-jni.cpp:25:35: error: use of undeclared identifier 'nullptr' IvwRes(size_t nSize) : buffer(nullptr), size(nSize) {

2 Answers

You need to configure C++ 11 support, on the version of compiler you have older one is default, and there nullptr is actually undefined.

If you do not need c++11, it's possible to just add define to compiler: in CMakeLists.txt add

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Dnullptr=0")
Related