Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Aug 1, 2023

Conversation

lethosor
Copy link
Member

@lethosor lethosor commented Aug 1, 2023

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".

DFhackDataExport const char * plugin_name = m_plugin_name;\
DFhackDataExport const char * plugin_version = DFHack::Version::dfhack_version();\
DFhackDataExport const char * plugin_git_description = DFHack::Version::git_description();\
DFhackDataExport int plugin_abi_version = DFHack::Version::dfhack_abi_version();\
DFhackDataExport DFHack::Plugin *plugin_self = NULL;\
std::vector<std::string> _plugin_globals;\
DFhackDataExport std::vector<std::string> _plugin_globals;\
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to export the underscore non-pointer version? is _plugin_globals referenced outside the plugin? I would think we'd only need the extern "C" change and not this export line.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line was left over from testing... you are probably right that this one doesn't need to be exported.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unresolved external symbol _plugin_globals -- might be fixed by reverting that line

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, pushing up a new version. I'm also going to switch away from the _ prefix, since that's reserved, and C globals actually get a _ prefix added so I'm not sure if that was potentially problematic.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Built successfully this time!

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"`.
@lethosor lethosor merged commit 9984dfe into DFHack:develop Aug 1, 2023
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants