需要一些帮助在编译jsoncpp示例代码(need some help in compiling a

2019-07-29 02:47发布

我想编个样品jsoncpp例子,但也有吨编译显示“标准”头了错误。 没有任何机构看到这个时间吗?

[~]$ g++ -g -c json.cc -I/usr/local/include/json 
In file included from /usr/include/libio.h:62,
                 from /usr/include/stdio.h:75,
                 from /usr/lib/gcc/i686-redhat-linux/4.4.6/../../../../include/c++/4.4.6/cstdio:45,
                 from json.cc:1:
/usr/include/sys/cdefs.h:46:44: error: missing binary operator before token "("
/usr/include/sys/cdefs.h:50:44: error: missing binary operator before token "("
/usr/include/sys/cdefs.h:135:19: error: missing binary operator before token "("
/usr/include/sys/cdefs.h:151:19: error: missing binary operator before token "("
/usr/include/sys/cdefs.h:209:19: error: missing binary operator before token "("
/usr/include/sys/cdefs.h:218:19: error: missing binary operator before token "("
/usr/include/sys/cdefs.h:227:19: error: missing binary operator before token "("
/usr/include/sys/cdefs.h:236:19: error: missing binary operator before token "("
/usr/include/sys/cdefs.h:248:19: error: missing binary operator before token "("
/usr/include/sys/cdefs.h:258:19: error: missing binary operator before token "("
/usr/include/sys/cdefs.h:267:19: error: missing binary operator before token "("
/usr/include/sys/cdefs.h:275:19: error: missing binary operator before token "("
/usr/include/sys/cdefs.h:289:19: error: missing binary operator before token "("
/usr/include/sys/cdefs.h:297:43: error: missing binary operator before token "("
/usr/include/sys/cdefs.h:326:19: error: missing binary operator before token "("
/usr/include/sys/cdefs.h:338:20: error: missing binary operator before token "("
/usr/include/sys/cdefs.h:343:20: error: missing binary operator before token "("
/usr/include/sys/cdefs.h:350:19: error: missing binary operator before token "("
In file included from /usr/lib/gcc/i686-redhat-linux/4.4.6/../../../../include/c++/4.4.6/cstring:45,
                 from json.cc:2:

Answer 1:

对我来说这是包含JSON-CPP与系统features.h在其他一些包括相互冲突的features.h。 我给它改名本地的JSON-CPP代码json_features.h,一切都很好。



Answer 2:

你需要使用这种方式来包含头文件的:#include“JSON / json.h”



Answer 3:

如果你有编译-I.../include/json ,那么标准库中可能会意外包含一个JSON头。 (在这种情况下,根据asuter,这是features.h 。)

父目录是一种“命名空间”的头文件。 这就是为什么对于像头任何库一个很好的做法incdir/foo/bar.h-Iincdir#include <foo/bar.h>



Answer 4:

检查JSON包含路径。 在编译选项使用-I/path of JSON include directory ,如-I$(pkg-config --cflags jsoncpp)



Answer 5:

这就是这种事情会发生,如果你的头在它之前有一个语法错误,如缺少的一个; 在类声明的末尾。 通过清理那些开始。



文章来源: need some help in compiling a jsoncpp sample code
标签: jsoncpp