VLink
2.0.0
A high-performance communication middleware
version.h
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2026 by Thun Lu. All rights reserved.
3
* Author: Thun Lu <thun.lu@zohomail.cn>
4
* Repo: https://github.com/thun-res/vlink
5
* _ __ __ _ __
6
* | | / / / / (_) ____ / /__
7
* | | / / / / / / / __ \ / //_/
8
* | |/ / / /___ / / / / / / / ,<
9
* |___/ /_____/ /_/ /_/ /_/ /_/|_|
10
*
11
* Licensed under the Apache License, Version 2.0 (the "License");
12
* you may not use this file except in compliance with the License.
13
* You may obtain a copy of the License at
14
*
15
* http://www.apache.org/licenses/LICENSE-2.0
16
*
17
* Unless required by applicable law or agreed to in writing, software
18
* distributed under the License is distributed on an "AS IS" BASIS,
19
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
* See the License for the specific language governing permissions and
21
* limitations under the License.
22
*/
23
24
/**
25
* @file version.h
26
* @brief VLink library version constants, build-time feature flags, and compile-time comparison helpers.
27
*
28
* @details
29
* This header is the single source of truth for the VLink library version
30
* triple and for the set of optional subsystems compiled into the build.
31
* When the CMake-generated @c version_config.h is present in the include
32
* tree it is preferred; otherwise the fallback @c #define block below
33
* supplies the default values used by header-only or out-of-tree builds.
34
*
35
* @par Version Macros
36
* | Macro | Type | Meaning |
37
* | ----------------------------- | ---------------- | --------------------------------------------------- |
38
* | @c VLINK_VERSION_MAJOR | integer literal | Major version component. |
39
* | @c VLINK_VERSION_MINOR | integer literal | Minor version component. |
40
* | @c VLINK_VERSION_PATCH | integer literal | Patch version component. |
41
* | @c VLINK_VERSION | string literal | Dot-separated version string, e.g. @c "2.0.0". |
42
* | @c VLINK_VERSION_TIMESTAMP | string literal | Build timestamp (empty in fallback builds). |
43
* | @c VLINK_VERSION_TAG | string literal | Git tag (empty in fallback builds). |
44
* | @c VLINK_VERSION_COMMIT_ID | string literal | Git commit hash (empty in fallback builds). |
45
* | @c VLINK_VERSION_CHECK(a,b,c) | 24-bit integer | Packs a version triple for compile-time compare. |
46
* | @c VLINK_VERSION_VALUE | 24-bit integer | Encoded current version for use with the check. |
47
*
48
* @par Feature-flag Macros (selected subset)
49
* | Macro | Subsystem |
50
* | --------------------------- | ---------------------------------------------------- |
51
* | @c VLINK_ENABLE_CXX_STD_20 | Compile-time opt-in to C++20 facilities. |
52
* | @c VLINK_ENABLE_C_API | Pure C wrapper API (see @c external/c_api.h). |
53
* | @c VLINK_ENABLE_SECURITY | Built-in security backends and @c Security* nodes. |
54
* | @c VLINK_ENABLE_SQLITE | SQLite-backed bag storage. |
55
* | @c VLINK_ENABLE_ZSTD | Zstd compression for bag files (off by default). |
56
* | @c VLINK_ENABLE_PROXY | Proxy monitoring API (see @c external/proxy_api.h). |
57
* | @c VLINK_ENABLE_CLI_* | Individual CLI sub-commands (info, bag, monitor...). |
58
* | @c VLINK_ENABLE_LOG_* | Optional logging back-ends (NAT, SPD, DLT, QUI). |
59
* | @c VLINK_ENABLE_TEST | Unit-test build artefacts. |
60
*
61
* @par Compile-time Version Check
62
* @code
63
* #include <vlink/version.h>
64
*
65
* #if VLINK_VERSION_VALUE >= VLINK_VERSION_CHECK(2, 0, 0)
66
* // Safe to use APIs introduced in VLink 2.0.0
67
* #endif
68
* @endcode
69
*
70
* @par Runtime Version Read
71
* @code
72
* #include <vlink/version.h>
73
* #include <iostream>
74
*
75
* void print_vlink_version() {
76
* std::cout << "VLink " << VLINK_VERSION << "\n"
77
* << " major = " << VLINK_VERSION_MAJOR << "\n"
78
* << " minor = " << VLINK_VERSION_MINOR << "\n"
79
* << " patch = " << VLINK_VERSION_PATCH << "\n";
80
* }
81
* @endcode
82
*/
83
84
#pragma once
85
86
#if __has_include("./vlink/version_config.h"
)
87
88
#include "./vlink/version_config.h"
89
90
#else
91
92
#define VLINK_VERSION_MAJOR 2
93
#define VLINK_VERSION_MINOR 0
94
#define VLINK_VERSION_PATCH 0
95
#define VLINK_VERSION "2.0.0"
96
#define VLINK_VERSION_TIMESTAMP ""
97
#define VLINK_VERSION_TAG ""
98
#define VLINK_VERSION_COMMIT_ID ""
99
100
#ifndef VLINK_ENABLE_CXX_STD_20
101
#if __cplusplus >= 202002L
102
#define VLINK_ENABLE_CXX_STD_20
103
#endif
104
#endif
105
106
#ifndef VLINK_ENABLE_C_API
107
#define VLINK_ENABLE_C_API
108
#endif
109
110
#ifndef VLINK_ENABLE_SECURITY
111
#define VLINK_ENABLE_SECURITY
112
#endif
113
114
#ifndef VLINK_ENABLE_ZSTD
115
// #define VLINK_ENABLE_ZSTD
116
#endif
117
118
#ifndef VLINK_ENABLE_SQLITE
119
#define VLINK_ENABLE_SQLITE
120
#endif
121
122
#ifndef VLINK_ENABLE_CLI_INFO
123
#define VLINK_ENABLE_CLI_INFO
124
#endif
125
126
#ifndef VLINK_ENABLE_CLI_BAG
127
#define VLINK_ENABLE_CLI_BAG
128
#endif
129
130
#ifndef VLINK_ENABLE_CLI_BENCH
131
#define VLINK_ENABLE_CLI_BENCH
132
#endif
133
134
#ifndef VLINK_ENABLE_CLI_EPROTO
135
#define VLINK_ENABLE_CLI_EPROTO
136
#endif
137
138
#ifndef VLINK_ENABLE_CLI_EFBS
139
#define VLINK_ENABLE_CLI_EFBS
140
#endif
141
142
#ifndef VLINK_ENABLE_CLI_LIST
143
#define VLINK_ENABLE_CLI_LIST
144
#endif
145
146
#ifndef VLINK_ENABLE_CLI_MONITOR
147
#define VLINK_ENABLE_CLI_MONITOR
148
#endif
149
150
#ifndef VLINK_ENABLE_CLI_DUMP
151
#define VLINK_ENABLE_CLI_DUMP
152
#endif
153
154
#ifndef VLINK_ENABLE_CLI_CHECK
155
#define VLINK_ENABLE_CLI_CHECK
156
#endif
157
158
#ifndef VLINK_ENABLE_LOG_QUI
159
// #define VLINK_ENABLE_LOG_QUI
160
#endif
161
162
#ifndef VLINK_ENABLE_LOG_SPD
163
// #define VLINK_ENABLE_LOG_SPD
164
#endif
165
166
#ifndef VLINK_ENABLE_LOG_DLT
167
// #define VLINK_ENABLE_LOG_DLT
168
#endif
169
170
#ifndef VLINK_ENABLE_LOG_NAT
171
#define VLINK_ENABLE_LOG_NAT
172
#endif
173
174
#ifndef VLINK_ENABLE_EXPRTK
175
// #define VLINK_ENABLE_EXPRTK
176
#endif
177
178
#ifndef VLINK_ENABLE_PROXY
179
#define VLINK_ENABLE_PROXY
180
#endif
181
182
#ifndef VLINK_ENABLE_VIEWER
183
// #define VLINK_ENABLE_VIEWER
184
#endif
185
186
#ifndef VLINK_ENABLE_WEBVIZ
187
// #define VLINK_ENABLE_WEBVIZ
188
#endif
189
190
#ifndef VLINK_ENABLE_SYMLINKS
191
// #define VLINK_ENABLE_SYMLINKS
192
#endif
193
194
#ifndef VLINK_ENABLE_COMPLETIONS
195
// #define VLINK_ENABLE_COMPLETIONS
196
#endif
197
198
#ifndef VLINK_ENABLE_EXAMPLES
199
// #define VLINK_ENABLE_EXAMPLES
200
#endif
201
202
#ifndef VLINK_ENABLE_EXAMPLES_ALL
203
// #define VLINK_ENABLE_EXAMPLES_ALL
204
#endif
205
206
#ifndef VLINK_ENABLE_TEST
207
#define VLINK_ENABLE_TEST
208
#endif
209
210
#endif
211
212
/**
213
* @def VLINK_VERSION_CHECK
214
* @brief Packs a (major, minor, patch) triple into a single 24-bit integer.
215
*
216
* @details
217
* Stores @p major in bits 23-16, @p minor in bits 15-8, and @p patch in
218
* bits 7-0. Use together with @c VLINK_VERSION_VALUE to write compile-time
219
* version guards.
220
*
221
* @param major Major component (0-255).
222
* @param minor Minor component (0-255).
223
* @param patch Patch component (0-255).
224
* @return Encoded 24-bit integer.
225
*/
226
#define VLINK_VERSION_CHECK(major, minor, patch) (((major) << 16) | ((minor) << 8) | (patch))
227
228
/**
229
* @def VLINK_VERSION_VALUE
230
* @brief The encoded 24-bit value for the current library version.
231
*
232
* @details
233
* Equivalent to
234
* @c VLINK_VERSION_CHECK(VLINK_VERSION_MAJOR, VLINK_VERSION_MINOR, VLINK_VERSION_PATCH).
235
* Compare against the output of @c VLINK_VERSION_CHECK to gate code paths
236
* on a minimum library version at compile time.
237
*/
238
#define VLINK_VERSION_VALUE VLINK_VERSION_CHECK(VLINK_VERSION_MAJOR, VLINK_VERSION_MINOR, VLINK_VERSION_PATCH)
include
vlink
version.h
Generated by
1.9.1