v icon indicating copy to clipboard operation
v copied to clipboard

json: support system cJSON library through pkgconfig

Open davidebeatrici opened this issue 2 years ago • 2 comments

We have to either wait for the next cJSON release or add a symbol check before merging: DaveGamble/cJSON#697

davidebeatrici avatar Aug 02 '22 04:08 davidebeatrici

It should not be the first choice/the default. The system provided cJSON library may be much older than what V expects.

You can use $if system_cjson ? { to surround the check, if you do want to support it as an option (i.e. the user will have to then compile with -d system_cjson passed to V).

spytheman avatar Aug 02 '22 07:08 spytheman

https://github.com/vlang/v/blob/fcde63127fdf7588cb54360ee25f4be96cbd5e2b/thirdparty/cJSON/cJSON.h#L81-L84

The latest version is currently 1.7.15, but cJSON_GetErrorPos() is missing because not upstreamed yet.

I agree that adding an option is probably the best solution right now.

davidebeatrici avatar Aug 02 '22 17:08 davidebeatrici

We prefer static linking for binaries generated by V. Especially for something that's part of the language.

medvednikov avatar Aug 16 '22 17:08 medvednikov

Understandable, the upstream pull request is not merged yet anyway.

davidebeatrici avatar Aug 16 '22 17:08 davidebeatrici