-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
Restructure inline namespace and allow version component to be disabled #3683
Restructure inline namespace and allow version component to be disabled #3683
Conversation
docs/mkdocs/docs/api/macros/nlohmann_json_namespace_version_namespace.md
Outdated
Show resolved
Hide resolved
docs/mkdocs/docs/api/macros/nlohmann_json_namespace_version_namespace.md
Outdated
Show resolved
Hide resolved
What is the benefit of having the version part a separate namespace that may or may not be used instead of just a part of the name that may or may not be there? |
It just expresses the hierarchy between the truly (and always) ABI-breaking settings and library versions. I don't really know yet if that's useful, but I don't think it hurts either. |
91fad9d
to
a2ac34c
Compare
ci_test_single_header failing is expected until #3679 is merged. |
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.
7811254
to
ce129a5
Compare
Is there a way to get back to the original behavior and just have a |
Yes. Since 3.11.0. |
ce129a5
to
dd6cfe2
Compare
I've added a first, rough version of |
docs/mkdocs/docs/api/macros/nlohmann_json_namespace_exclude_version.md
Outdated
Show resolved
Hide resolved
nlohmann::nlohmann_json_diag::v3_11_2 | ||
``` | ||
|
||
## Disabling the version namespace |
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.
I had another thought on the documentation.
The current documentation describes what the namespace is and how to manipulate the default behavior. Maybe it should be structured as follows:
- describe that starting in 3.11.0 we changed the namespace from
nlohmann
to a more elaborate version - describe why this is a benefit - maybe by explicitly listing the incompatibilities that were possible before, but would not have been caught before; maybe also mention
JSON_SKIP_LIBRARY_VERSION_CHECK
- describe how the namespace is structured
- describe the 3 different styles the namespace can be configured:
- default - note: this is fine until we have a better means to describe ABI compatibility (right?)
- no version part - note: this is fine if the library user wants to take the risk of mixing libraries with different versions, but with same ABI tags
nlohmann
- note: use at your own risk (maybe also show the approach of extern from/to_json result in linker error #3657 (comment))
What do you think?
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.
I already had planned on addressing this, so thanks for the outline.
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.
I didn't quite adopt the outline and made a note to take another look and incorporate more of your ideas.
For now, I think what I have is as good as it's going to get in 2 passes.
dd6cfe2
to
aaca005
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.
Minor doc issue rest looks good to me.
- ABI test produces namespace names as expected.
- GDB pretty printer works with the new namespace layout.
- mkdocs pass style check.
- Examples outputs regenerated.
- docset index is complete (minus operator pages already in
upstream/develop
). - Did I forget anything?
types. | ||
|
||
There is an exception when forward declarations are used (i.e., when including `json_fwd.hpp`) in which case the linker | ||
may complain about undefined references. |
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.
I want to extend this part with an example but don't have it in me right now. :-)
To do so, define [`NLOHMANN_JSON_NAMESPACE_NO_VERSION`](../api/macros/nlohmann_json_namespace_no_version.md) to `1`. | ||
|
||
This applies to version 3.11.2 and above only, versions 3.11.0 and 3.11.1 can apply the technique described in the next | ||
section to emulate the effect of the `NLOHMANN_JSON_NAMESPACE_NO_VERSION` macro. |
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.
I did not provide an example here as this will hopefully be an exceedingly rare use case.
aaca005
to
5385b05
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.
Looks good to me.
Restructure the inline namespace, moving the version component to the end and renaming the prefix to
json_abi
.Example:
nlohmann::json_abi_diag_v3_11_1
The prefix of the tag namespace cannot be
json
as that would conflict with the type aliasnlohmann::json
.The version namespace can be disabled by defining
NLOHMANN_JSON_NAMESPACE_NO_VERSION
to1
.