关闭

linux下使用Jsoncpp

441人阅读 评论(0) 收藏 举报
分类:

linux下使用Jsoncpp源码与项目代码一起编译时,会出现很多报错,诸如:

error: missing binary operator before token "("

/usr/include/wchar.h:104:1: error: ‘__BEGIN_NAMESPACE_C99’ does not name a type
/usr/include/wchar.h:107:1: error: ‘__END_NAMESPACE_C99’ does not name a type
/usr/include/wchar.h:135:1: error: ‘__END_NAMESPACE_STD’ does not name a type
/usr/include/wchar.h:149:6: error: expected initializer before ‘__THROW’
/usr/include/wchar.h:153:39: error: expected initializer before ‘__THROW’
/usr/include/wchar.h:157:6: error: expected initializer before ‘__THROW’
/usr/include/wchar.h:161:6: error: expected initializer before ‘__THROW’

/usr/include/c++/4.6/cwchar:143:11: error: ‘::btowc’ has not been declared
/usr/include/c++/4.6/cwchar:144:11: error: ‘::fgetwc’ has not been declared
/usr/include/c++/4.6/cwchar:148:11: error: ‘::fwide’ has not been declared
/usr/include/c++/4.6/cwchar:149:11: error: ‘::fwprintf’ has not been declared
/usr/include/c++/4.6/cwchar:150:11: error: ‘::fwscanf’ has not been declared

/usr/include/c++/4.6/cwchar:215:55: error: invalid conversion from ‘const wchar_t*’ to ‘wchar_t*’ [-fpermissive]
/usr/include/c++/4.6/cwchar:214:3: error:   initializing argument 1 of ‘wchar_t* std::wcschr(wchar_t*, wchar_t)’ [-fpermissive]

/usr/include/locale.h: At global scope:
/usr/include/locale.h:32:1: error: ‘__BEGIN_DECLS’ does not name a type
/usr/include/locale.h:125:65: error: expected initializer before ‘__THROW’
/usr/include/locale.h:128:40: error: expected initializer before ‘__THROW’
/usr/include/locale.h:130:1: error: ‘__END_NAMESPACE_STD’ does not name a type

......

产生原因:jsoncpp中有一个features.h文件,在/usr/include下也有一个同名的文件,所以就出现文件依赖顺序等问题,一旦搞混,就报了一堆错

解决办法:

网上看了下解决办法,有的是把json库放在/usr/local/include/目录下,然后再#include "json/json.h"。

当然最简单的办法就是把jsoncpp的features.h重命名,然后json.h与reader.h要引用它,在相应的位置换成新的文件名字就ok了

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:3862次
    • 积分:111
    • 等级:
    • 排名:千里之外
    • 原创:6篇
    • 转载:8篇
    • 译文:0篇
    • 评论:0条
    文章分类