Fix C++20 global module fragment inclusion #1047
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Using the experimental C++20 modules support in recent builds of Clang, EnTT currently causes compilation errors when included as part of the global module fragment in a module interface unit that exports part of EnTT's API and is then imported and used by a different translation unit. Here is a minimal example (note the "error: no matching function for call to 'popcount'" in the output): https://godbolt.org/z/9vTjz9Prh
The reason seems to be that certain function declarations that are implicitly required by the implementation aren't exported into the module interface since they are erroneously marked 'static' and have internal linkage when they should (presumably) be 'inline'. I found that changing these declarations accordingly fixed the problem and made EnTT work well with C++20 modules in my project, and this PR reflects those changes.
Unfortunately I can't write proper test cases for this since it depends on features that are still experimental in most compilers, so there may still be other static declarations that I have missed that could cause problems in other modules-based projects, but as long as these changes don't break anything for regular non-modules builds, they should hopefully at least help make EnTT a bit more modules-friendly in the short term.