ibireme / yyjson

The fastest JSON library in C
https://ibireme.github.io/yyjson/doc/doxygen/html/
MIT License
2.98k stars 262 forks source link

Remove static qualifiers to support wrapping in other languages #165

Closed nordlow closed 1 week ago

nordlow commented 3 months ago

I'm currently developing a wrapper for yyjson in D.

However the inline qualifier macro(s) on some API functions prevents them from being callable as an extern(C) functions. Would it possible to remove the static qualifer part in those macros?

TkTech commented 3 months ago

No part of the public API should be marked as inline, what are you trying to wrap?

ibireme commented 3 months ago

Maybe you could try this:

// create a new file, e.g. yyjson_ext.c
#define yyjson_api_inline yyjson_api
#include yyjson.h
nordlow commented 2 months ago

Search for yyjson_api_inline in yyjson.h.

nordlow commented 2 months ago

I suggest changing

#ifndef yyjson_api_inline
#   define yyjson_api_inline static yyjson_inline
#endif

to

#ifndef yyjson_api_inline
#   define yyjson_api_inline yyjson_inline
#endif

in yyjson.h. Shall I create a PR that does this?

ibireme commented 2 months ago

@nordlow No, the static keyword is used to limit the scope of these functions to the current source file. If we simply remove static and make these functions inline, it could potentially lead to naming collisions and linker errors in some environments.