-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
Add versioned, ABI-tagged inline namespace and namespace macros #3590
Conversation
Can these be updated by https://github.com/nlohmann/json_release_scripts/blob/main/scripts/bump_version/bump_version.py? |
Yes. I already have a modified version, although that script needs several updates because of other changes. |
Now that I've switched to macros, updating the version via Overall, the solution isn't all that pretty - with or without macros. Also, I'm strongly leaning toward adding special unit tests for these changes (see To Do in the description). |
a3afc53
to
47dbf10
Compare
Note to self: 196f0acc7e39de04b730a5f33f038da9af2847f2 "Replace uses of nlohmann namespace with macro" |
c27d0d2
to
57f7dc0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this eliminate the need for this check, or does it simply mean that we only need to check for versions prior to 3.11.0 being included?
Could we have a test of an object created with JSON_DIAGNOSTICS 1
being passed to a function defined in a file with JSON_DIAGNOSTICS 0
? I'm hoping that it fails with a reasonable error message, but it could also copy, like ordered_json
to json
.
Yes, I could see splitting this up into something like "macros which affect the definition of the |
I've added |
I think it is still useful. Including multiple versions in one translation unit can potentially be handled by ordering the includes carefully and creating using aliases with the current value of
Will do. If it converts, that would be a problematic outcome. |
Oh, it's just a warning. I was thinking it was an error. |
Alright, I've spent some time building a test that passes a Inline namespaces only solve the use case where multiple components use the JSON library internally but don't expose those objects to the user. I still think interoperability is possible with very carefully written glue code. That's what I'll try next (using The documentation needs some more work in light of this. |
I was not aware of inline namespaces. Thanks for adding this. I found https://www.foonathan.net/2018/11/inline-namespaces/ pretty useful. |
This reminds me that I wanted to rethink the documentation changes around arbitrary type conversion. |
dd0c855
to
01f6c23
Compare
Add a versioned inline namespace to prevent ABI issues when linking code using multiple library versions.
Add _diag suffix to inline namespace if JSON_DIAGNOSTICS is enabled, and _ldvcmp suffix if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON is enabled.
a88aa79
to
478fded
Compare
@nlohmann I'm done here. Ready for review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
Since nlohmann/json#3590, the basic_json class and the json using-declaration are located in a "versioned, ABI-tagged inline namespace". This makes it impossible to forward declare the type in REveElement.hxx. Instead introduce a new struct REveJsonWrapper that just wraps a json object (after including the full nlohmann/json.hpp). As the struct is under our control, we can easily forward declare the type and use it for method arguments.
Since nlohmann/json#3590, the basic_json class and the json using-declaration are located in a "versioned, ABI-tagged inline namespace". This makes it impossible to forward declare the type in REveElement.hxx. Instead introduce a new struct REveJsonWrapper that just wraps a json object (after including the full nlohmann/json.hpp). As the struct is under our control, we can easily forward declare the type and use it for method arguments. Fixes root-project#11130
NLOHMANN_JSON_NAMESPACE_BEGIN
,NLOHMANN_JSON_NAMESPACE_END
,NLOHMANN_JSON_NAMESPACE
.Fixes #3588.
Fixes #3360.
To Do:
JSON_DIAGNOSTICS
on and off is now supported.nlohmann
namespace (adl_serializer
, are there more?).