T-Box Basic dev
Loading...
Searching...
No Matches
version.h
Go to the documentation of this file.
1
10
11#ifndef __TBOX_VERSION_H__
12#define __TBOX_VERSION_H__
13#pragma once
14
20
21/* clang-format off */
22
28#define TBOX_VERSION_MAJOR 0
29
35#define TBOX_VERSION_MINOR 1
36
42#define TBOX_VERSION_PATCH 0
43
49#define TBOX_VERSION_STRING "0.1.0"
50
56#define TBOX_CONFIGURED_API (TBOX_VERSION_MAJOR * 10000 + TBOX_VERSION_MINOR * 100)
57
63#define TBOX_COMMIT_SHORT "a53dfab"
64
70#define TBOX_COMMIT_LONG "a53dfab9b6df800caf10f0ed5a36b6d083cf0681"
71
77#define TBOX_BUILD_DATE __DATE__
78
84#define TBOX_BUILD_TIME __TIME__
85
86/* clang-format on */
87
91
97
98/* Helper macros for CPP string composition */
99#define TBOX_MSTR_HELPER(x) #x
100#define TBOX_MSTR(x) TBOX_MSTR_HELPER(x)
101
102/*
103 * Generic deprecation macro
104 *
105 * If TBOX_SUPPRESS_DEPRECATED is defined, then TBOX_DEPRECATED and
106 * TBOX_DEPRECATED_FOR become no-ops
107 */
108#ifndef TBOX_DEPRECATED
109#undef TBOX_DEPRECATED_FOR
110#ifndef TBOX_SUPPRESS_DEPRECATED
111#if defined(_MSC_VER)
112/*
113 * MSVC supports __declspec(deprecated) since MSVC 2003 (13.10),
114 * and __declspec(deprecated(message)) since MSVC 2005 (14.00)
115 */
116#if _MSC_VER >= 1400
117#define TBOX_DEPRECATED(since) __declspec(deprecated("Since T-Box " #since))
118#define TBOX_DEPRECATED_FOR(since, message) __declspec(deprecated("Since T-Box " #since ";" message))
119#define TBOX_DEPRECATED_MESSAGE(message) __declspec(deprecated(message))
120#elif _MSC_VER >= 1310
121#define TBOX_DEPRECATED(since) __declspec(deprecated)
122#define TBOX_DEPRECATED_FOR(since, message) __declspec(deprecated)
123#define TBOX_DEPRECATED_MESSAGE(message) __declspec(deprecated)
124#endif
125#define TBOX_BEGIN_ALLOW_DEPRECATED __pragma(warning(push)) __pragma(warning(disable : 4996))
126#define TBOX_END_ALLOW_DEPRECATED __pragma(warning(pop))
127#elif defined(__GNUC__)
128/*
129 * According to GCC documentation, deprecations with message appeared in
130 * GCC 4.5.0
131 */
132#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
133#define TBOX_DEPRECATED(since) __attribute__((deprecated("Since T-Box " #since)))
134#define TBOX_DEPRECATED_FOR(since, message) __attribute__((deprecated("Since T-Box " #since ";" message)))
135#define TBOX_DEPRECATED_MESSAGE(message) __attribute__((deprecated(message)))
136#elif __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 0)
137#define TBOX_DEPRECATED(since) __attribute__((deprecated))
138#define TBOX_DEPRECATED_FOR(since, message) __attribute__((deprecated))
139#define TBOX_DEPRECATED_MESSAGE(message) __attribute__((deprecated))
140#endif
141#define TBOX_BEGIN_ALLOW_DEPRECATED \
142 _Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
143#define TBOX_END_ALLOW_DEPRECATED _Pragma("GCC diagnostic pop")
144#elif defined(__SUNPRO_C)
145#if (__SUNPRO_C >= 0x5130)
146#define TBOX_DEPRECATED(since) __attribute__((deprecated))
147#define TBOX_DEPRECATED_FOR(since, message) __attribute__((deprecated))
148#define TBOX_DEPRECATED_MESSAGE(message) __attribute__((deprecated))
149#endif /* (__SUNPRO_C >= 0x5130) */
150#define TBOX_BEGIN_ALLOW_DEPRECATED #pragma error_messages(off, E_DEPRECATED_ATT, E_DEPRECATED_ATT_MESS)
151#define TBOX_END_ALLOW_DEPRECATED #pragma error_messages(on, E_DEPRECATED_ATT, E_DEPRECATED_ATT_MESS)
152#endif /* __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) */
153#endif /* _MSC_VER */
154#endif /* TBOX_DEPRECATED */
155
156/*
157 * Still not defined? Then define no-op macros. This means these macros
158 * are unsuitable for use in a typedef except TBOX_DEPRECATED_MESSAGE.
159 */
160#ifndef TBOX_DEPRECATED
161#define TBOX_DEPRECATED(since) extern
162#define TBOX_DEPRECATED_FOR(since, message) extern
163#define TBOX_DEPRECATED_MESSAGE(message)
164#define TBOX_BEGIN_ALLOW_DEPRECATED
165#define TBOX_END_ALLOW_DEPRECATED
166#endif /* TBOX_DEPRECATED */
167
168/*
169 * Applications should use -DTBOX_API_COMPAT=<version> to suppress the
170 * declarations of functions deprecated in or before <version>. If this is
171 * undefined, the value of the macro TBOX_CONFIGURED_API is the default.
172 *
173 * For our version numbering scheme, <version> is expected to be a computation
174 * of the major and minor numbers in decimal using this formula:
175 *
176 * MAJOR * 10000 + MINOR * 100
177 *
178 * So version 1.0 becomes 10000, version 2.2 becomes 20200, etc.
179 */
180
181/*
182 * We use the TBOX_API_COMPAT value to define API level macros. These
183 * macros are used to enable or disable features at that API version boundary.
184 */
185
186#ifdef TBOX_API_LEVEL
187#error "TBOX_API_LEVEL must not be defined by application"
188#endif
189
190/*
191 * We figure out what API level was intended by simple numeric comparison.
192 * The lowest old style number we recognise is 0x10000L, so we take some
193 * safety margin and assume that anything below 0x00900000L is a new style
194 * number. This allows new versions up to and including v943.71.83.
195 */
196#ifdef TBOX_API_COMPAT
197#if TBOX_API_COMPAT < 0x00900000L
198#define TBOX_API_LEVEL TBOX_API_COMPAT
199#else
200#define TBOX_API_LEVEL \
201 (((TBOX_API_COMPAT >> 28) & 0xF) * 10000 + ((TBOX_API_COMPAT >> 20) & 0xFF) * 100 + \
202 ((TBOX_API_COMPAT >> 12) & 0xFF))
203#endif
204#endif
205
206/*
207 * If TBOX_API_COMPAT wasn't given, we use default numbers to set
208 * the API compatibility level.
209 */
210#ifndef TBOX_API_LEVEL
211#if TBOX_CONFIGURED_API > 0
212#define TBOX_API_LEVEL (TBOX_CONFIGURED_API)
213#else
214#define TBOX_API_LEVEL (TBOX_VERSION_MAJOR * 10000 + TBOX_VERSION_MINOR * 100)
215#endif
216#endif
217
218#if TBOX_API_LEVEL > TBOX_CONFIGURED_API
219#error "The requested API level higher than the configured API compatibility level"
220#endif
221
222/*
223 * Check of sane values.
224 */
225/* Can't go higher than the current version. */
226#if TBOX_API_LEVEL > (TBOX_VERSION_MAJOR * 10000 + TBOX_VERSION_MINOR * 100)
227#error "TBOX_API_COMPAT expresses an impossible API compatibility level"
228#endif
229
230/*
231 * Define macros for deprecation and simulated removal purposes.
232 *
233 * The macros TBOX_DEPRECATEDIN_{major}_{minor} are always defined for
234 * all SSS Application versions we care for. They can be used as attributes
235 * in function declarations where appropriate.
236 *
237 * The macros TBOX_NO_DEPRECATED_{major}_{minor} are defined for
238 * all SSS Application versions up to or equal to the version given with
239 * TBOX_API_COMPAT. They are used as guards around anything that's
240 * deprecated up to that version, as an effect of the developer option
241 * 'no-deprecated'.
242 */
243
244#undef TBOX_NO_DEPRECATED_1_0_0
245
246#if TBOX_API_LEVEL >= 10000
247#ifndef TBOX_NO_DEPRECATED
248#define TBOX_DEPRECATEDIN_1_0_0 TBOX_DEPRECATED(1.0.0)
249#define TBOX_DEPRECATEDIN_1_0_0_FOR(msg) TBOX_DEPRECATED_FOR(1.0.0, msg)
250#else
251#define TBOX_NO_DEPRECATED_1_0_0
252#endif
253#else
254#define TBOX_DEPRECATEDIN_1_0_0
255#define TBOX_DEPRECATEDIN_1_0_0_FOR(msg)
256#endif
257
261
262#endif /* __TBOX_VERSION_H__ */