Cthulhu  0.2.10
Cthulhu compiler collection
macros.h
Go to the documentation of this file.
1 // SPDX-License-Identifier: LGPL-3.0-only
2 
3 #pragma once
4 
5 #include "core/compiler.h"
6 
11 
12 #if __cpp_static_assert >= 200410L
13 # define CT_STATIC_ASSERT(expr, msg) static_assert(expr, msg)
14 #else
15 # define CT_STATIC_ASSERT(expr, msg) _Static_assert(expr, msg)
16 #endif
17 
18 #if CT_HAS_ATTRIBUTE(deprecated)
19 # define CT_DEPRECATED(msg) [[deprecated(msg)]]
20 #elif defined(_MSC_VER)
21 # define CT_DEPRECATED(msg) __declspec(deprecated(msg))
22 #elif CT_HAS_ATTRIBUTE(__deprecated__)
23 # define CT_DEPRECATED(msg) __attribute__((__deprecated__(msg)))
24 #else
25 # define CT_DEPRECATED(msg)
26 #endif
27 
31 
34 #define CT_MAX(L, R) ((L) > (R) ? (L) : (R))
35 
38 #define CT_MIN(L, R) ((L) < (R) ? (L) : (R))
39 
42 #define CT_ALIGN_POW2(X, ALIGN) (((X) + (ALIGN)-1) & ~((ALIGN)-1))
43 
46 #define CT_UNUSED(x) ((void)(x))
47 
50 #define CT_INNER_STR(x) #x
51 #define CT_STR(x) CT_INNER_STR(x)
52 
55 #define CT_CONCAT(a, b) a##b
56 
59 #define CT_VERSION_STR CT_STR(CTU_VERSION_MAJOR) "." CT_STR(CTU_VERSION_MINOR) "." CT_STR(CTU_VERSION_PATCH)
60 
63 #define CT_ARRAY_LEN(arr) (sizeof(arr) / sizeof(*arr)) // NOLINT(bugprone-sizeof-expression)
64 
71 
72 #define CT_ANSI_RED "\x1B[1;31m"
73 #define CT_ANSI_GREEN "\x1B[1;32m"
74 #define CT_ANSI_YELLOW "\x1B[1;33m"
75 #define CT_ANSI_BLUE "\x1B[1;34m"
76 #define CT_ANSI_MAGENTA "\x1B[1;35m"
77 #define CT_ANSI_CYAN "\x1B[1;36m"
78 #define CT_ANSI_WHITE "\x1B[1;37m"
79 
80 #define CT_ANSI_RESET "\x1B[0m"
81 
83 
90 
91 #define CT_EXIT_OK 0
92 #define CT_EXIT_ERROR 1
93 #define CT_EXIT_SHOULD_EXIT 2
94 #define CT_EXIT_INTERNAL 99
95 
97