ApprovalTests.cpp
ApprovalTests.cpp copied to clipboard
Use constexpr to define version numbers, not #define
This arose out of #91.
It would be better to use constexpr
instead of #define
to define the version number components of this project in code - for type-safety.
Not everyone who uses this project uses it with CMake, so I would stick with our current structure - but I see that constexpr is a nicer - type-safe - way of setting the various version numbers...
I'll set up a separate issue to convert the
#define
approach in toconstexpr
instead...
Originally posted by @claremacrae in https://github.com/approvals/ApprovalTests.cpp/issues/91#issuecomment-589946545
Current situation:
We use this:
https://github.com/approvals/ApprovalTests.cpp/blob/d997f56343ac70db621fd36593fa55b87b4eb975/build/prepare_release.py#L62-L81
To generate this:
https://github.com/approvals/ApprovalTests.cpp/blob/d997f56343ac70db621fd36593fa55b87b4eb975/ApprovalTests/ApprovalTestsVersion.h#L1-L13
See the following template for the intention of this ticket...
https://github.com/jwillikers/cmake_configure_version_header/blob/fa644a6db6d61b7ac6dffce738bcb038fa4e6bd7/src/version.hpp.in#L1-L14
Instead of the @...@
text, our Python script would insert actual values.
We need to think about the use of a namespace, though - It would be a breaking change to add this now...
And we would use char[]
instead of std::string_view
We're marking this as on_hold, as no current plans to implement it...
It doesn't have to be a breaking change, if we add this as a new mechanism, and keep the old one...