我正在使用Qt Creator使用C ++ 11。
"warning: identifier 'nullptr' is a keyword in C++11 [-Wc++0x-compat]"
"error: 'nullptr' was not declared in this scope"
这是在其他地方可以使用的代码,相关部分是:
... = nullptr;
可能是什么问题?
这还不是关键字,不是全球范围吗?
从QtCreator内部打开.pro
文件并添加此
QMAKE_CXXFLAGS += -std=c++0x
尝试将以下几行添加到您的cpp源代码中
#ifndef _GXX_NULLPTR_T
#define _GXX_NULLPTR_T
typedef decltype(nullptr) nullptr_t;
#endif
/* C++11 */