forkachild / C-Simple-JSON-Parser

Extremely lightweight, easy-to-use & blazing fast JSON parsing library written in pure C
https://forkachild.github.io/C-Simple-JSON-Parser/
MIT License
45 stars 16 forks source link

incompatible point type passed to json_object_find function #12

Closed kwjones closed 1 year ago

kwjones commented 1 year ago

Nice library by the way, but I did find issue that requires correction. I'm using gcc version 11.+ on Ubuntu 22.04. Using your test example from the README.md. (I only added which is generally required to output to stderr. Here's the compile and run error (segmentation fault):

GCC VERSION INFO ubuntu@ip-172-31-87-157:~/dev/C-Simple-JSON-Parser$ gcc --version gcc (Ubuntu 11.2.0-19ubuntu1) 11.2.0 Copyright (C) 2021 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

GCC COMPILATION ubuntu@ip-172-31-87-157:~/dev/C-Simple-JSON-Parser$ gcc parse_with_error_checking.c json.c -o parse_with_error_checking parse_with_error_checking.c: In function ‘main’: parse_with_error_checking.c:20:64: warning: passing argument 1 of ‘json_object_find’ from incompatible pointer type [-Wincompatible-pointer-types] 20 result(json_element) hello_element_result = json_object_find(&element, "hello"); ^~~~
json_element_t {aka struct json_element_s }

In file included from parse_with_error_checking.c:2: json.h:156:60: note: expected ‘json_object_t ’ {aka ‘struct json_object_s ’} but argument is of type ‘json_element_t ’ {aka ‘struct json_element_s ’} 156 | result(json_element) json_object_find(typed(json_object) * object, typed(json_string) key); | ^

EXECUTABLE RUNTIME MESSAGES ubuntu@ip-172-31-87-157:~/dev/C-Simple-JSON-Parser$ ./parse_with_error_checking Segmentation fault (core dumped) ubuntu@ip-172-31-87-157:~/dev/C-Simple-JSON-Parser$

forkachild commented 1 year ago

Thank you for finding this. It is now fixed in release v2.2

15