Skip to content
This repository was archived by the owner on Jun 4, 2026. It is now read-only.

Fix template instantiations and visibility - #45

Open
kkaefer wants to merge 1 commit into
masterfrom
template-instantiations-visibility
Open

Fix template instantiations and visibility#45
kkaefer wants to merge 1 commit into
masterfrom
template-instantiations-visibility

Conversation

@kkaefer

Copy link
Copy Markdown
Member

The *_impl.hpp files has defects when instantiating the promised symbols. Instead of this template specialization declaration:

template <> geometry parse<geometry>(const std::string &);

it should’ve been a template instantiation:

template geometry parse<geometry>(const std::string &);

Additionally, it introduces a few macros that allow controlling symbol visibility:

Adds MAPBOX_GEOJSON_VISIBILITY, MAPBOX_GEOJSON_RAPIDJSON_VISIBILITY, and MAPBOX_GEOJSON_VALUE_VISIBILITY. If defined (e.g. to __attribute__((visibility ("default")))) they will allow you to set the visiblity of the symbols for the *_impl.hpp files. MAPBOX_GEOJSON_VISIBILITY propagates to the other two, so if you just want parse/stringify, but e.g. not RapidJSON explicitly define the other two to be empty.

I used nm to check that the shared library includes the correct public symbols:

geojson parse(std::const string&)
geojson parse<geojson>(std::const string&)
feature_collection parse<feature_collection>(std::const string&)
feature parse<feature>(std::const string&)
geometry parse<geometry>(std::const string&)
std::string stringify(const geojson&)
std::string stringify<geojson>(const geojson&)
std::string stringify<feature_collection>(const feature_collection&)
std::string stringify<feature>(const feature&)
std::string stringify<geometry>(const geometry&)
geojson convert(const rapidjson_value&)
geojson convert<geojson>(const rapidjson_value&)
feature_collection convert<feature_collection>(const rapidjson_value&)
feature convert<feature>(const rapidjson_value&)
geometry convert<geometry>(const rapidjson_value&)
rapidjson_value convert(const geojson&, rapidjson_allocator&)
rapidjson_value convert<geojson>(const geojson&, rapidjson_allocator&)
rapidjson_value convert<feature_collection>(const feature_collection&, rapidjson_allocator&)
rapidjson_value convert<feature>(const feature&, rapidjson_allocator&)
rapidjson_value convert<geometry>(const geometry&, rapidjson_allocator&)
geojson convert(const value&)
geojson convert<geojson>(const value&)
feature_collection convert<feature_collection>(const value&)
feature convert<feature>(const value&)
geometry convert<geometry>(const value&)
value convert(const geojson&)
value convert<geojson>(const geojson&)
value convert<feature_collection>(const feature_collection&)
value convert<feature>(const feature&)
value convert<geometry>(const geometry&)

The *_impl.hpp files included some template specialization declarations that were supposed to be instantiations.
Adds MAPBOX_GEOJSON_VISIBILITY, MAPBOX_GEOJSON_RAPIDJSON_VISIBILITY, and MAPBOX_GEOJSON_VALUE_VISIBILITY. If defined (e.g. to `__attribute__((visibility ("default")))`) they will allow you to set the visiblity of the symbols for the *_impl.hpp files. MAPBOX_GEOJSON_VISIBILITY propagates to the other two, so if you just want parse/stringify, but e.g. not RapidJSON explicitly define the other two to be empty.
@kkaefer
kkaeferforce-pushed the template-instantiations-visibility branch from 3828e34 to 1464641CompareMarch 15, 2021 09:11
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@kkaefer@alexshalamov