cJSON
cJSON copied to clipboard
simplify the use of *nix symbol exports
It is generally never wrong to avoid setting the symbol visibility to default for public symbols. It is already checked for compilers that actually support the attribute.
The visibility define merely tells the compiler that the symbol is semantically an interface symbol. This is already the default for all symbols. The real purpose of the attribute is simply to override -fvisibility passed on the command line.
On *nix, you can set visibility for both shared and static libraries without harm anyway.
Despite this, respect the "hidden symbols" option. There's no actual use for creating a shared library without symbols, and it's essentially a no-op for static libraries, but in the static library case one might be including cJSON into another shared library, and not want to expose the cJSON symbols.
Therefore, make the header directly respect this option, rather than conditionalizing it on the CMakeLists.txt both setting the hidden symbols define and undefining the visibility define.
but in the static library case one might be including cJSON into another shared library, and not want to expose the cJSON symbols.
(This is anyways likely better done via -Wl,--exclude-libs,ALL
to exclude exporting symbols in all static libraries being linked to.)