Loading...
Searching...
No Matches
Go to the documentation of this file.
3#define ZEROERR_VERSION_MAJOR 0
4#define ZEROERR_VERSION_MINOR 3
5#define ZEROERR_VERSION_PATCH 0
6#define ZEROERR_VERSION \
7 (ZEROERR_VERSION_MAJOR * 10000 + ZEROERR_VERSION_MINOR * 100 + ZEROERR_VERSION_PATCH)
9#define ZEROERR_STR(x) #x
11#define ZEROERR_VERSION_STR_BUILDER(a, b, c) ZEROERR_STR(a) "." ZEROERR_STR(b) "." ZEROERR_STR(c)
12#define ZEROERR_VERSION_STR \
13 ZEROERR_VERSION_STR_BUILDER(ZEROERR_VERSION_MAJOR, ZEROERR_VERSION_MINOR, ZEROERR_VERSION_PATCH)
38#define ZEROERR_CPLUSPLUS _MSVC_LANG
40#define ZEROERR_CPLUSPLUS __cplusplus
43#if ZEROERR_CPLUSPLUS >= 202300L
44#define ZEROERR_CXX_STANDARD 23
45#elif ZEROERR_CPLUSPLUS >= 202002L
46#define ZEROERR_CXX_STANDARD 20
47#elif ZEROERR_CPLUSPLUS >= 201703L
48#define ZEROERR_CXX_STANDARD 17
49#elif ZEROERR_CPLUSPLUS >= 201402L
50#define ZEROERR_CXX_STANDARD 14
51#elif ZEROERR_CPLUSPLUS >= 201103L
52#define ZEROERR_CXX_STANDARD 11
54#error "Unsupported C++ standard detected. ZeroErr requires C++11 or later."
57#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
58#define ZEROERR_OS_UNIX
60#define ZEROERR_OS_LINUX
62#elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
63#define ZEROERR_OS_WINDOWS
65#define ZEROERR_OS_UNKNOWN
69#if defined(NDEBUG) && !defined(ZEROERR_ALWAYS_ASSERT)
75#define ZEROERR_CAT_IMPL(s1, s2) s1##s2
76#define ZEROERR_CAT(x, s) ZEROERR_CAT_IMPL(x, s)
80#define ZEROERR_ARG16(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, ...) _15
81#define ZEROERR_HAS_COMMA(...) \
82 ZEROERR_ARG16(__VA_ARGS__, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0)
83#define ZEROERR_TRIGGER_PARENTHESIS_(...) ,
85#define ZEROERR_ISEMPTY(...) \
88 ZEROERR_HAS_COMMA(__VA_ARGS__),
90 ZEROERR_HAS_COMMA(ZEROERR_TRIGGER_PARENTHESIS_ \
93 ZEROERR_HAS_COMMA(__VA_ARGS__( \
96 ZEROERR_HAS_COMMA(ZEROERR_TRIGGER_PARENTHESIS_ __VA_ARGS__()))
98#define ZEROERR_PASTE5(_0, _1, _2, _3, _4) _0##_1##_2##_3##_4
99#define _ZEROERR_ISEMPTY(_0, _1, _2, _3) \
100 ZEROERR_HAS_COMMA(ZEROERR_PASTE5(_IS_EMPTY_CASE_, _0, _1, _2, _3))
101#define _IS_EMPTY_CASE_0001 ,
106#define ZEROERR_NAMEGEN(x) ZEROERR_CAT(x, __COUNTER__)
108#define ZEROERR_NAMEGEN(x) ZEROERR_CAT(x, __LINE__)
111#ifdef ZEROERR_OS_LINUX
115#ifdef ZEROERR_DISABLE_ASSERTS_RETURN_VALUES
116#define ZEROERR_FUNC_SCOPE_BEGIN do
117#define ZEROERR_FUNC_SCOPE_END while (0)
118#define ZEROERR_FUNC_SCOPE_RET(v) (void)0
120#define ZEROERR_FUNC_SCOPE_BEGIN [&]
121#define ZEROERR_FUNC_SCOPE_END ()
122#define ZEROERR_FUNC_SCOPE_RET(v) return v
125#ifndef ZEROERR_NO_SHORT_LOG_MACRO
126#define ZEROERR_USE_SHORT_LOG_MACRO
129#define ZEROERR_EXPAND(x) x
136#define ZEROERR_COMPILER(MAJOR, MINOR, PATCH) ((MAJOR) * 10000000 + (MINOR) * 100000 + (PATCH))
139#if defined(_MSC_VER) && defined(_MSC_FULL_VER)
140#if _MSC_VER == _MSC_FULL_VER / 10000
141#define ZEROERR_MSVC ZEROERR_COMPILER(_MSC_VER / 100, _MSC_VER % 100, _MSC_FULL_VER % 10000)
143#define ZEROERR_MSVC \
144 ZEROERR_COMPILER(_MSC_VER / 100, (_MSC_FULL_VER / 100000) % 100, _MSC_FULL_VER % 100000)
147#if defined(__clang__) && defined(__clang_minor__) && defined(__clang_patchlevel__)
148#define ZEROERR_CLANG ZEROERR_COMPILER(__clang_major__, __clang_minor__, __clang_patchlevel__)
149#elif defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__) && \
150 !defined(__INTEL_COMPILER)
151#define ZEROERR_GCC ZEROERR_COMPILER(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
153#if defined(__INTEL_COMPILER)
154#define ZEROERR_ICC ZEROERR_COMPILER(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0)
158#define ZEROERR_MSVC 0
161#define ZEROERR_CLANG 0
175#if ZEROERR_CLANG && !ZEROERR_ICC
176#define ZEROERR_PRAGMA_TO_STR(x) _Pragma(#x)
177#define ZEROERR_CLANG_SUPPRESS_WARNING_PUSH _Pragma("clang diagnostic push")
178#define ZEROERR_CLANG_SUPPRESS_WARNING(w) ZEROERR_PRAGMA_TO_STR(clang diagnostic ignored w)
179#define ZEROERR_CLANG_SUPPRESS_WARNING_POP _Pragma("clang diagnostic pop")
180#define ZEROERR_CLANG_SUPPRESS_WARNING_WITH_PUSH(w) \
181 ZEROERR_CLANG_SUPPRESS_WARNING_PUSH ZEROERR_CLANG_SUPPRESS_WARNING(w)
183#define ZEROERR_CLANG_SUPPRESS_WARNING_PUSH
184#define ZEROERR_CLANG_SUPPRESS_WARNING(w)
185#define ZEROERR_CLANG_SUPPRESS_WARNING_POP
186#define ZEROERR_CLANG_SUPPRESS_WARNING_WITH_PUSH(w)
190#define ZEROERR_PRAGMA_TO_STR(x) _Pragma(#x)
191#define ZEROERR_GCC_SUPPRESS_WARNING_PUSH _Pragma("GCC diagnostic push")
192#define ZEROERR_GCC_SUPPRESS_WARNING(w) ZEROERR_PRAGMA_TO_STR(GCC diagnostic ignored w)
193#define ZEROERR_GCC_SUPPRESS_WARNING_POP _Pragma("GCC diagnostic pop")
194#define ZEROERR_GCC_SUPPRESS_WARNING_WITH_PUSH(w) \
195 ZEROERR_GCC_SUPPRESS_WARNING_PUSH ZEROERR_GCC_SUPPRESS_WARNING(w)
197#define ZEROERR_GCC_SUPPRESS_WARNING_PUSH
198#define ZEROERR_GCC_SUPPRESS_WARNING(w)
199#define ZEROERR_GCC_SUPPRESS_WARNING_POP
200#define ZEROERR_GCC_SUPPRESS_WARNING_WITH_PUSH(w)
204#define ZEROERR_MSVC_SUPPRESS_WARNING_PUSH __pragma(warning(push))
205#define ZEROERR_MSVC_SUPPRESS_WARNING(w) __pragma(warning(disable : w))
206#define ZEROERR_MSVC_SUPPRESS_WARNING_POP __pragma(warning(pop))
207#define ZEROERR_MSVC_SUPPRESS_WARNING_WITH_PUSH(w) \
208 ZEROERR_MSVC_SUPPRESS_WARNING_PUSH ZEROERR_MSVC_SUPPRESS_WARNING(w)
210#define ZEROERR_MSVC_SUPPRESS_WARNING_PUSH
211#define ZEROERR_MSVC_SUPPRESS_WARNING(w)
212#define ZEROERR_MSVC_SUPPRESS_WARNING_POP
213#define ZEROERR_MSVC_SUPPRESS_WARNING_WITH_PUSH(w)
222#define ZEROERR_SUPPRESS_COMMON_WARNINGS_PUSH \
223 ZEROERR_CLANG_SUPPRESS_WARNING_PUSH \
224 ZEROERR_CLANG_SUPPRESS_WARNING("-Wunknown-pragmas") \
225 ZEROERR_CLANG_SUPPRESS_WARNING("-Wweak-vtables") \
226 ZEROERR_CLANG_SUPPRESS_WARNING("-Wpadded") \
227 ZEROERR_CLANG_SUPPRESS_WARNING("-Wmissing-prototypes") \
228 ZEROERR_CLANG_SUPPRESS_WARNING("-Wc++98-compat") \
229 ZEROERR_CLANG_SUPPRESS_WARNING("-Wc++98-compat-pedantic") \
231 ZEROERR_GCC_SUPPRESS_WARNING_PUSH \
232 ZEROERR_GCC_SUPPRESS_WARNING("-Wunknown-pragmas") \
233 ZEROERR_GCC_SUPPRESS_WARNING("-Wpragmas") \
234 ZEROERR_GCC_SUPPRESS_WARNING("-Weffc++") \
235 ZEROERR_GCC_SUPPRESS_WARNING("-Wstrict-overflow") \
236 ZEROERR_GCC_SUPPRESS_WARNING("-Wstrict-aliasing") \
237 ZEROERR_GCC_SUPPRESS_WARNING("-Wmissing-declarations") \
238 ZEROERR_GCC_SUPPRESS_WARNING("-Wuseless-cast") \
239 ZEROERR_GCC_SUPPRESS_WARNING("-Wnoexcept") \
241 ZEROERR_MSVC_SUPPRESS_WARNING_PUSH \
243 ZEROERR_MSVC_SUPPRESS_WARNING(4514) \
244 ZEROERR_MSVC_SUPPRESS_WARNING(4571) \
245 ZEROERR_MSVC_SUPPRESS_WARNING(4710) \
246 ZEROERR_MSVC_SUPPRESS_WARNING(4711) \
248 ZEROERR_MSVC_SUPPRESS_WARNING(4616) \
249 ZEROERR_MSVC_SUPPRESS_WARNING(4619) \
250 ZEROERR_MSVC_SUPPRESS_WARNING(4996) \
251 ZEROERR_MSVC_SUPPRESS_WARNING(4706) \
252 ZEROERR_MSVC_SUPPRESS_WARNING(4512) \
253 ZEROERR_MSVC_SUPPRESS_WARNING(4127) \
254 ZEROERR_MSVC_SUPPRESS_WARNING(4820) \
255 ZEROERR_MSVC_SUPPRESS_WARNING(4625) \
256 ZEROERR_MSVC_SUPPRESS_WARNING(4626) \
257 ZEROERR_MSVC_SUPPRESS_WARNING(5027) \
258 ZEROERR_MSVC_SUPPRESS_WARNING(5026) \
259 ZEROERR_MSVC_SUPPRESS_WARNING(4640) \
260 ZEROERR_MSVC_SUPPRESS_WARNING(5045) \
261 ZEROERR_MSVC_SUPPRESS_WARNING(5264) \
263 ZEROERR_MSVC_SUPPRESS_WARNING(26439) \
264 ZEROERR_MSVC_SUPPRESS_WARNING(26495) \
265 ZEROERR_MSVC_SUPPRESS_WARNING(26451) \
266 ZEROERR_MSVC_SUPPRESS_WARNING(26444) \
267 ZEROERR_MSVC_SUPPRESS_WARNING(26812)
269#define ZEROERR_SUPPRESS_COMMON_WARNINGS_POP \
270 ZEROERR_CLANG_SUPPRESS_WARNING_POP \
271 ZEROERR_GCC_SUPPRESS_WARNING_POP \
272 ZEROERR_MSVC_SUPPRESS_WARNING_POP
275#define ZEROERR_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN \
276 ZEROERR_MSVC_SUPPRESS_WARNING_PUSH \
277 ZEROERR_MSVC_SUPPRESS_WARNING(4548) \
278 ZEROERR_MSVC_SUPPRESS_WARNING(4265) \
279 ZEROERR_MSVC_SUPPRESS_WARNING(4986) \
280 ZEROERR_MSVC_SUPPRESS_WARNING(4350) \
281 ZEROERR_MSVC_SUPPRESS_WARNING(4668) \
282 ZEROERR_MSVC_SUPPRESS_WARNING(4365) \
283 ZEROERR_MSVC_SUPPRESS_WARNING(4774) \
284 ZEROERR_MSVC_SUPPRESS_WARNING(4820) \
285 ZEROERR_MSVC_SUPPRESS_WARNING(4625) \
286 ZEROERR_MSVC_SUPPRESS_WARNING(4626) \
287 ZEROERR_MSVC_SUPPRESS_WARNING(5027) \
288 ZEROERR_MSVC_SUPPRESS_WARNING(5026) \
289 ZEROERR_MSVC_SUPPRESS_WARNING(4623) \
290 ZEROERR_MSVC_SUPPRESS_WARNING(5039) \
291 ZEROERR_MSVC_SUPPRESS_WARNING(5045) \
292 ZEROERR_MSVC_SUPPRESS_WARNING(5105) \
293 ZEROERR_MSVC_SUPPRESS_WARNING(4738) \
294 ZEROERR_MSVC_SUPPRESS_WARNING(5262)
296#define ZEROERR_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END ZEROERR_MSVC_SUPPRESS_WARNING_POP
298#define ZEROERR_SUPPRESS_VARIADIC_MACRO \
299 ZEROERR_CLANG_SUPPRESS_WARNING_WITH_PUSH("-Wgnu-zero-variadic-macro-arguments")
301#define ZEROERR_SUPPRESS_VARIADIC_MACRO_POP ZEROERR_CLANG_SUPPRESS_WARNING_POP
303#define ZEROERR_SUPPRESS_COMPARE \
304 ZEROERR_CLANG_SUPPRESS_WARNING_PUSH \
305 ZEROERR_CLANG_SUPPRESS_WARNING("-Wsign-conversion") \
306 ZEROERR_CLANG_SUPPRESS_WARNING("-Wsign-compare") \
307 ZEROERR_CLANG_SUPPRESS_WARNING("-Wgnu-zero-variadic-macro-arguments") \
308 ZEROERR_GCC_SUPPRESS_WARNING_PUSH \
309 ZEROERR_GCC_SUPPRESS_WARNING("-Wsign-conversion") \
310 ZEROERR_GCC_SUPPRESS_WARNING("-Wsign-compare") \
311 ZEROERR_MSVC_SUPPRESS_WARNING_PUSH \
312 ZEROERR_MSVC_SUPPRESS_WARNING(4388) \
313 ZEROERR_MSVC_SUPPRESS_WARNING(4389) \
314 ZEROERR_MSVC_SUPPRESS_WARNING(4018)
316#define ZEROERR_SUPPRESS_COMPARE_POP \
317 ZEROERR_CLANG_SUPPRESS_WARNING_POP ZEROERR_GCC_SUPPRESS_WARNING_POP \
318 ZEROERR_MSVC_SUPPRESS_WARNING_POP
337#if ZEROERR_CLANG || ZEROERR_GCC
338#define ZEROERR_UNUSED(x) x __attribute__((unused))
339#elif defined(__LCLINT__)
340#define ZEROERR_UNUSED(x) x
342#define ZEROERR_UNUSED(x) \
343 ZEROERR_MSVC_SUPPRESS_WARNING_WITH_PUSH(4100) x ZEROERR_MSVC_SUPPRESS_WARNING_POP
345#define ZEROERR_UNUSED(x) x