vc使用jsoncpp头文件冲突问题

编译时出现

1>d:\program files (x86)\microsoft visual studio 9.0\vc\include\xdebug(32) : warning C4229: 使用了记时错误 : 忽略数据上的修饰符
1>d:\program files (x86)\microsoft visual studio 9.0\vc\include\xdebug(32) : error C2365: “operator new”: 重定义;以前的定义是“函数”
1>d:\program files (x86)\microsoft visual studio 9.0\vc\include\xdebug(32) : error C2078: 初始值设定项太多
1>d:\program files (x86)\microsoft visual studio 9.0\vc\include\xdebug(32) : error C2440: “初始化”: 无法从“int”转换为“void *”
1>d:\program files (x86)\microsoft visual studio 9.0\vc\include\xlocale(343) : error C2227: “->_Name”的左边必须指向类/结构/联合/泛型类型
1>d:\program files (x86)\microsoft visual studio 9.0\vc\include\xlocale(343) : error C2228: “.c_str”的左边必须有类/结构/联合
1>d:\program files (x86)\microsoft visual studio 9.0\vc\include\xlocale(344) : error C2065: “_Cat”: 未声明的标识符
1>d:\program files (x86)\microsoft visual studio 9.0\vc\include\xlocale(344) : error C2065: “_Other”: 未声明的标识符
1>d:\program files (x86)\microsoft visual studio 9.0\vc\include\xlocale(344) : error C2228: “._Ptr”的左边必须有类/结构/联合
1>d:\program files (x86)\microsoft visual studio 9.0\vc\include\xlocale(344) : fatal error C1003: 错误计数超过 100;正在停止编译



jsoncpp的代码拿着好久了,一直不能加入到自己库,总出现这些错误,一直没搞明白怎么回事

今天无意中发现是debug版本中是new在作怪

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

搞的好纠结的,印象中试过几次 都没找着问题,哎..

解决方式如下:修改json.h


#ifndef JSON_JSON_H_INCLUDED
# define JSON_JSON_H_INCLUDED

#ifdef new
	#define REDEFINE_NEW
	#undef new
#endif // new


//# include "autolink.h"
# include "value.h"
# include "reader.h"
# include "writer.h"
# include "features.h"

#ifdef REDEFINE_NEW
	#define new DEBUG_NEW	
#endif // REDEFINE_NEW

#endif // JSON_JSON_H_INCLUDED

先取消new的DEBUG_NEW宏定义,尾巴上再重新定义宏,完美解决呀..

得养成好习惯,头文件中不能写的代码不能写... 我是有个模板类的头文件中使用了DEBUG_NEW宏,没法


posted @ 2016-03-25 01:20  eATM  阅读(693)  评论(0编辑  收藏  举报