Fix mangling of `plugin_globals` with GCC's C++11 ABI

Without being declared with `extern "C"`, `plugin_globals` is mangled, with a
`cxx11` suffix.

We can't add `extern "C"` to the `DFhackDataExport` macro because GCC does not
allow initializing any `extern` variables inline, including `extern "C"`.
develop
lethosor 2023-08-01 00:08:30 -04:00
parent 53c90affa1
commit 73f96209da
No known key found for this signature in database
GPG Key ID: 76A269552F4F58C1
1 changed files with 5 additions and 3 deletions

@ -298,14 +298,16 @@ namespace DFHack
}; };
#define DFHACK_PLUGIN_AUX(m_plugin_name, is_dev) \ #define DFHACK_PLUGIN_AUX(m_plugin_name, is_dev) \
extern "C" { \
DFhackDataExport const char * plugin_name = m_plugin_name;\ DFhackDataExport const char * plugin_name = m_plugin_name;\
DFhackDataExport const char * plugin_version = DFHack::Version::dfhack_version();\ DFhackDataExport const char * plugin_version = DFHack::Version::dfhack_version();\
DFhackDataExport const char * plugin_git_description = DFHack::Version::git_description();\ DFhackDataExport const char * plugin_git_description = DFHack::Version::git_description();\
DFhackDataExport int plugin_abi_version = DFHack::Version::dfhack_abi_version();\ DFhackDataExport int plugin_abi_version = DFHack::Version::dfhack_abi_version();\
DFhackDataExport DFHack::Plugin *plugin_self = NULL;\ DFhackDataExport DFHack::Plugin *plugin_self = NULL;\
std::vector<std::string> _plugin_globals;\ std::vector<std::string> plugin_globals_noptr;\
DFhackDataExport std::vector<std::string>* plugin_globals = &_plugin_globals; \ DFhackDataExport std::vector<std::string>* plugin_globals = &plugin_globals_noptr; \
DFhackDataExport bool plugin_dev = is_dev; DFhackDataExport bool plugin_dev = is_dev; \
}
/// You have to include DFHACK_PLUGIN("plugin_name") in every plugin you write - just once. Ideally at the top of the main file. /// You have to include DFHACK_PLUGIN("plugin_name") in every plugin you write - just once. Ideally at the top of the main file.
#ifdef DEV_PLUGIN #ifdef DEV_PLUGIN