我在使用 g++ 4.9.2 编译并设置了 -std=c++11 标志的 linux 项目上使用 C++ Rest SDK。
内部 C++ Rest SDK 会像这样检查 nullptr 是否存在:
#if defined nullptr_t
#define NEEDS_NULLPTR_DEFINED 0
#else
#define NEEDS_NULLPTR_DEFINED 1
#endif
#if NEEDS_NULLPTR_DEFINED
#define nullptr NULL
#endif
此检查在我的机器上失败导致 nullptr 被定义为 NULL,这会破坏之后的编译。我不太确定是 g++ 还是 C++ Rest SDK 导致了这个问题。
您是否知道为什么此 nullptr_t 检查在 g++ 4.9.2 中失败以及如何修复它?
编辑:
我向 C++ REST SDK 提交了一个问题:https://casablanca.codeplex.com/workitem/340
最佳答案
nullptr_t
不是由预处理器定义的,所以让预处理器检查它是行不通的。 nullptr
在g++-4.9.2
中定义为-std=c++11
,一个快速测试程序可以验证。
int main() {
std::nullptr_t i = nullptr;
}
关于c++ - nullptr_t 未在 g++ 4.9.2 上定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28199162/