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.
I have finally figured out the issues preventing me from using the single-header rmkit across multiple TUs.
There were a few namespace-level global static variables. If such variables are not
externorinline, each TU will get their own uninitialized copy of the field.This resulted in a build that throws no warnings at all, but segfaults at runtime when we try to read a null font, or the FB singleton is empty and we get no render.
I've used
externinstead ofinlinebecause rmkit's build process complains about inline and there are already other fields with extern and that clever initializer generation. There should be no difference between the two, but inline is only in C++>=17I think these were the only such fields left in rmkit. My application seems to work fine now with these changes.
I had to learn a lot about C++ to figure this out, so here's what I've got:
The only problems are namespace-level static variables and static variables within an inlined function. Static variables at the class/struct level work as you'd expect across TUs. Static and inline functions are also fine and work as expected, so long as they don't touch local static or namespace-static variables.