Use an inline namespace to distinguish emitted symbols by version numbers#291
Merged
ToruNiina merged 3 commits intoToruNiina:mainfrom May 17, 2025
Merged
Conversation
9ccc3ff to
5b3d75e
Compare
ToruNiina
reviewed
May 16, 2025
Co-authored-by: Toru Niina <niina.toru.68u@gmail.com>
Owner
|
toml-test is failing due to upstream changes around new features in 1.1.0. This is not an issue of your patch. Some features that caused discussion seems to be reverted from TOML v1.1.0. I will update it later. if all other tests pass, I will merge this. |
Owner
|
I confirmed that example/reflect works after applying your patch. now all the todos in your comment are done. merging. thanks! |
github-actions bot
pushed a commit
that referenced
this pull request
May 17, 2025
Use an inline namespace to distinguish emitted symbols by version numbers e4051f7
Contributor
Author
|
Thank you too! |
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This is a trick commonly used to ensure that header-only C++ libraries which are used only internally at build-time do not emit conflicting symbols if the library is used in multiple packages, possibly in different version numbers (see e.g. the STL).
With this PR, the symbols produced by toml11 in downstream code contain the library's current version number:
This avoids conflicts when trying to link two packages that both internally use toml11 in conflicting versions.
The
inline namespaceensures that application programmers do not need to change any code since the effect of inline namespaces is only on the ABI, not on the API.Note: I will not be able to respond next week. Feel free to modify the PR as needed.
TODO:
examples/reflect/reflect.hpp: While this PR is generally not API-breaking, it probably does break the API for use in reflection. I could simply apply the necessary change there too, but I do not know the consequences that this would have on user code.