Skip to content

Consider changing our inline namespace name with each release #5976

@devjgm

Description

@devjgm

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

  1. 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.
  2. We should announce this change in the CHANGELOG.md.
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: cleanupAn internal cleanup or hygiene concern.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions