dasmig-core 1.2.0
Shared random engine, distributions and data tiers for the dasmig generator libraries
Loading...
Searching...
No Matches
version.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// Copyright (c) 2020-2026 Diego Dasso Migotto
3
4#ifndef DASMIG_CORE_VERSION_HPP
5#define DASMIG_CORE_VERSION_HPP
6
7/// @file version.hpp
8/// @brief dasmig-core version and the compatibility check used by libraries.
9/// @author Diego Dasso Migotto (diegomigotto at hotmail dot com)
10
11// The version must be a macro: DASMIG_CORE_REQUIRE checks it at the
12// preprocessor and static_assert level across vendored copies.
13// NOLINTBEGIN(cppcoreguidelines-macro-usage)
14
15/// @brief Major version. Changes when generated output or the API changes
16/// incompatibly.
17#define DASMIG_CORE_VERSION_MAJOR 1
18/// @brief Minor version. Changes when features are added compatibly.
19#define DASMIG_CORE_VERSION_MINOR 2
20/// @brief Patch version. Changes for fixes that keep output identical.
21#define DASMIG_CORE_VERSION_PATCH 0
22
23/// @brief Fails compilation unless the core in use is compatible with the
24/// version a library was built against.
25///
26/// Every library vendors its own copy of the core. When two libraries are
27/// included in one translation unit, the include guards keep only the first
28/// copy, so a library must check that the copy actually in use is
29/// compatible: same major version, and at least the minor version it needs.
30///
31/// @code
32/// #include "core.hpp"
33/// DASMIG_CORE_REQUIRE(1, 2);
34/// @endcode
35#define DASMIG_CORE_REQUIRE(major, minor) \
36 static_assert(DASMIG_CORE_VERSION_MAJOR == (major) && \
37 DASMIG_CORE_VERSION_MINOR >= (minor), \
38 "dasmig-core version mismatch: the libraries included in " \
39 "this translation unit vendor incompatible core versions")
40// NOLINTEND(cppcoreguidelines-macro-usage)
41
42namespace dasmig::core
43{
44
45/// @brief A semantic version.
47{
48 int major; ///< Major version.
49 int minor; ///< Minor version.
50 int patch; ///< Patch version.
51};
52
53/// @brief The version of the core in use.
57
58} // namespace dasmig::core
59
60#endif // DASMIG_CORE_VERSION_HPP
A semantic version.
Definition version.hpp:47
int patch
Patch version.
Definition version.hpp:50
int minor
Minor version.
Definition version.hpp:49
int major
Major version.
Definition version.hpp:48
constexpr version_t version
The version of the core in use.
Definition version.hpp:54
#define DASMIG_CORE_VERSION_MINOR
Minor version. Changes when features are added compatibly.
Definition version.hpp:19
#define DASMIG_CORE_VERSION_MAJOR
Major version. Changes when generated output or the API changes incompatibly.
Definition version.hpp:17
#define DASMIG_CORE_VERSION_PATCH
Patch version. Changes for fixes that keep output identical.
Definition version.hpp:21