TR_datastructures 0.1.0
A generic C data structures library
Loading...
Searching...
No Matches
tr_version.h
Go to the documentation of this file.
1/**
2 * @file tr_version.h
3 * @brief Version information for the tr_datastructures library
4 *
5 * This file is automatically generated by CMake from
6 * @c cmake/tr_version.h.in — do not edit manually.
7 * The version numbers are taken directly from the @c VERSION
8 * field in the root @c CMakeLists.txt.
9 *
10 * Example usage:
11 * @code
12 * #include "tr_datastructures/tr_version.h"
13 *
14 * #if TR_VERSION_AT_LEAST(1, 0, 0)
15 * // use features from 1.0.0 onwards
16 * #endif
17 *
18 * printf("TR_datastructures version: %s\n", TR_VERSION_STRING);
19 * @endcode
20 */
21/*******************************************************************************************************
22* NAME: tr_version.h
23*
24* PURPOSE: Version information for the tr_datastructures library
25* This file is generated by CMake - do not edit manually
26*
27* GLOBAL VARIABLES: None
28*
29* DEVELOPMENT HISTORY:
30*
31* Date Author Change Id Release Description Of Change
32* ---------- --------------- --------- ------- -----------------------------------
33* 24-05-2026 Tiago Rodrigues 1 File preparation
34*
35*******************************************************************************************************/
36#ifndef TR_VERSION_H
37#define TR_VERSION_H
38
39/* 0 copyright/licensing */
40/*******************************************************************************************************
41*
42* This is free and unencumbered software released into the public domain (Unlicense).
43*
44********************************************************************************************************/
45
46#ifdef __cplusplus
47extern "C" {
48#endif
49
50
51/* 1 includes */
52/*****************************************************/
53/*****************************************************/
54
55
56/* 2 defines */
57/*****************************************************/
58
59/* ------------------------------------------------------------------
60 * 2.1 Version numbers
61 * These are automatically populated by CMake from the project()
62 * VERSION field in the root CMakeLists.txt
63 * ------------------------------------------------------------------ */
64
65 /**
66 * @defgroup tr_version_numbers Version Number Macros
67 * @{
68 *
69 * @brief Individual version component macros
70 *
71 * These are set automatically by CMake from the project VERSION field.
72 * Prefer @ref TR_VERSION_AT_LEAST for version comparisons.
73 *
74 * | Macro | Description | Example |
75 * |--------------------|--------------------------|---------|
76 * | TR_VERSION_MAJOR | Major version number | 0 |
77 * | TR_VERSION_MINOR | Minor version number | 1 |
78 * | TR_VERSION_PATCH | Patch version number | 0 |
79 * | TR_VERSION_STRING | Full version as a string | "0.1.0" |
80 */
81
82#define TR_VERSION_MAJOR 0 /**< Major version number */
83#define TR_VERSION_MINOR 1 /**< Minor version number */
84#define TR_VERSION_PATCH 0 /**< Patch version number */
85#define TR_VERSION_STRING "0.1.0" /**< Full version string */
86
87/** @} */ /* end of tr_version_numbers group */
88
89
90/* ------------------------------------------------------------------
91 * 2.2 Version encoding
92 * Encodes the full version into a single integer for easy comparison
93 * e.g. version 1.2.3 becomes 0x00010203
94 * Usage: #if TR_VERSION >= TR_VERSION_ENCODE(1, 2, 0)
95 * ------------------------------------------------------------------ */
96/**
97 * @brief Encodes major, minor and patch into a single integer
98 *
99 * Packs three version components into a single 32 bit integer
100 * for easy numerical comparison. The encoding is:
101 * @code
102 * (major << 16) | (minor << 8) | patch
103 * @endcode
104 *
105 * Example — version 1.2.3 encodes to 0x00010203:
106 * @code
107 * #if TR_VERSION >= TR_VERSION_ENCODE(1, 2, 0)
108 * // version is at least 1.2.0
109 * #endif
110 * @endcode
111 *
112 * @param major Major version component
113 * @param minor Minor version component
114 * @param patch Patch version component
115 */
116#define TR_VERSION_ENCODE(major, minor, patch) \
117 (((major) << 16) | ((minor) << 8) | (patch))
118
119/**
120 * @brief Current library version encoded as a single integer
121 *
122 * Combines @ref TR_VERSION_MAJOR, @ref TR_VERSION_MINOR and
123 * @ref TR_VERSION_PATCH into a single integer using
124 * @ref TR_VERSION_ENCODE. Use with @ref TR_VERSION_AT_LEAST
125 * for version checks.
126 *
127 * Example:
128 * @code
129 * printf("Version code: 0x%06X\n", TR_VERSION);
130 * @endcode
131 */
132#define TR_VERSION \
133 TR_VERSION_ENCODE(TR_VERSION_MAJOR, TR_VERSION_MINOR, TR_VERSION_PATCH)
134
135
136/* ------------------------------------------------------------------
137 * 2.3 Version check macro
138 * Returns 1 if the current version is at least major.minor.patch
139 * Usage: #if TR_VERSION_AT_LEAST(1, 2, 0)
140 * ------------------------------------------------------------------ */
141/**
142 * @brief Checks if the current version is at least major.minor.patch
143 *
144 * The recommended way to perform compile time version checks.
145 * Evaluates to 1 if the current library version is greater than
146 * or equal to the specified version, 0 otherwise.
147 *
148 * Example:
149 * @code
150 * #if TR_VERSION_AT_LEAST(1, 0, 0)
151 * // safe to use features added in 1.0.0
152 * #endif
153 * @endcode
154 *
155 * @param major Required major version
156 * @param minor Required minor version
157 * @param patch Required patch version
158 */
159#define TR_VERSION_AT_LEAST(major, minor, patch) \
160 (TR_VERSION >= TR_VERSION_ENCODE(major, minor, patch))
161
162
163// clang-format off
164/*****************************************************/
165
166/* 3 external declarations */
167/*****************************************************/
168/*****************************************************/
169
170/* 4 typedefs */
171/*****************************************************/
172/*****************************************************/
173
174/* 5 global variable declarations */
175/*****************************************************/
176/*****************************************************/
177
178/* 6 function prototypes */
179/*****************************************************/
180/*****************************************************/
181// clang-format on
182
183
184#ifdef __cplusplus
185}
186#endif
187
188#endif /* TR_VERSION_H */