We use an inline namespace in our code to help with library versioning. For example:
|
namespace google { |
|
namespace cloud { |
|
namespace spanner { |
|
inline namespace SPANNER_CLIENT_NS { |
which today resolves to v1 for all of our libraries. We rarely change this inline namespace name.
The purpose of using an an inline namespace is to allow for versioning at the API and ABI levels. However, for this to actually work, we should change the inline namespace anytime we make an API or ABI change. An easy way to do this is to simply change the inline namespace name with every release.
Proposal
We should change the GOOGLE_CLOUD_CPP_NS define
|
#define GOOGLE_CLOUD_CPP_VCONCAT(Ma, Mi) v##Ma |
|
#define GOOGLE_CLOUD_CPP_VEVAL(Ma, Mi) GOOGLE_CLOUD_CPP_VCONCAT(Ma, Mi) |
|
#define GOOGLE_CLOUD_CPP_NS \ |
|
GOOGLE_CLOUD_CPP_VEVAL(GOOGLE_CLOUD_CPP_VERSION_MAJOR, \ |
|
GOOGLE_CLOUD_CPP_VERSION_MINOR) |
to include the whole released version.
For example, the currently released version is v1.25.0, and so the inline namespace name should probably expand to v1_25_0
Other considerations
- We should update our Support docs to specify how we expect users to use inline namespaces. In general, users should not name the inline namespace. This shortens their code and gives them a path to upgrading to newer versions without breaking, as long as they recompile. Users should only spell the inline namespace name when they tightly depend on a specific version. This should be rare. By default, users should not spell the inline namespace name. I believe this is all standard C++ advice that would likely apply to any C++ code that uses inline namespaces.
- We should announce this change in the
CHANGELOG.md.
- What should be the inline namespace name for the unreleased code at
HEAD? We could use the next library version, but that's not really correct, because the eventual release with that version will be different. We could use the string head, which is what Abseil does. Or we could use something like v1_26_0_preview.
We use an
inline namespacein our code to help with library versioning. For example:google-cloud-cpp/google/cloud/spanner/numeric.h
Lines 30 to 33 in b5b37ac
which today resolves to
v1for all of our libraries. We rarely change this inline namespace name.The purpose of using an an inline namespace is to allow for versioning at the API and ABI levels. However, for this to actually work, we should change the inline namespace anytime we make an API or ABI change. An easy way to do this is to simply change the inline namespace name with every release.
Proposal
We should change the
GOOGLE_CLOUD_CPP_NSdefinegoogle-cloud-cpp/google/cloud/version.h
Lines 22 to 26 in b5b37ac
to include the whole released version.
For example, the currently released version is v1.25.0, and so the inline namespace name should probably expand to
v1_25_0Other considerations
CHANGELOG.md.HEAD? We could use the next library version, but that's not really correct, because the eventual release with that version will be different. We could use the stringhead, which is what Abseil does. Or we could use something likev1_26_0_preview.