错误信息:
error C2059: syntax error : 'constant'
*\JsonCpp\Value.h(126) : error C2574: 'Json::Value::Value(void)' : cannot be declared static

原因
  目前的项目在用mongodb和jsoncpp,使用的mongodb版本的头文件中有一个宏定义“#define null (0)”,同时jsoncpp的Value类有一个常量“static const Value null;”,两个null命名冲突导致的问题,即当包含的头文件顺序使得mongodb的null宏在jsoncpp的null常量之前被包含,那么jsoncpp中的null标识符会被替换成“(0)”,从而导致语法错误,如下面的例子所示:

#define null (0) //"mogodb/include/mongo/stdafx.h"

class Value //"JsonCpp/Value.h"
{
private:
static const Value null;
};

上面例子产生的编译错误:
error C2059: syntax error : 'constant'
error C2574: 'Value::Value(void)' : cannot be declared static

相关文章:

  • 2021-11-06
  • 2022-03-08
  • 2021-07-26
  • 2021-09-08
  • 2022-12-23
  • 2022-01-10
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-03
  • 2022-02-06
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案