在Visual Studio中包含json-c库时遇到错误

lmvvr0a8  于 2023-03-01  发布在  其他
关注(0)|答案(1)|浏览(187)

我需要在visual studio中解析c代码中的json文件。但是当我包含json-c头时,我得到了错误。我该如何解决这些问题呢?

#include<ntddk.h>
#include<wdf.h>
#include<fwpmk.h>
#include<fwpsk.h>
#define INITGUID
#include<guiddef.h>
#include<fwpmu.h>

#undef _CRT_STRINGIZE
#undef _CRT_WIDE
#undef __CRTDECL
#include<json-c/json.h>
#include<json-c/json_object.h>

The errors are:

Severity    Code    Description Project File    Line    Suppression State
Warning C6067   _Param_(2) in call to 'DbgPrint' must be the address of a string. Actual type: 'void *'.    WfpcalloutDriver3   C:\Users\hp\Desktop\VK\WfpcalloutDriver3\Source.c   88  
Warning C4083   expected ')'; found identifier '_VCRUNTIME_DISABLED_WARNINGS'   WfpcalloutDriver3   C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\stdint.h    16  
Error   C2220   the following warning is treated as an error    WfpcalloutDriver3   C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\vcruntime.h 61  
Warning C4083   expected ')'; found identifier '_VCRUNTIME_DISABLED_WARNINGS'   WfpcalloutDriver3   C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\vcruntime.h 61  
Warning C4005   '_CRT_STRINGIZE': macro redefinition    WfpcalloutDriver3   C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\vcruntime.h 111 
Warning C4005   '_CRT_WIDE': macro redefinition WfpcalloutDriver3   C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\vcruntime.h 114 
Warning C4005   '__CRTDECL': macro redefinition WfpcalloutDriver3   C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\vcruntime.h 155
d5vmydt9

d5vmydt91#

刚刚看了一下github页面,上面写着(强调我的):
要使用json-c,您可以包含json. h、或最好包含,后者是以下更具体的头文件之一:

json_object.h - Core types and methods.
json_tokener.h - Methods for parsing and serializing json-c object trees.
json_pointer.h - JSON Pointer (RFC 6901) implementation for retrieving objects from a json-c object tree.
json_object_iterator.h - Methods for iterating over single json_object instances. (See also json_object_object_foreach() in json_object.h)
json_visit.h - Methods for walking a tree of json-c objects.
json_util.h - Miscellaneous utility functions.

所以,看起来你包含了json. h * 和 * json_object. h。这就解释了宏的重定义。试着去掉#include<json-c/json.h>

相关问题