MCRO
C++23 utilities for Unreal Engine.
Loading...
Searching...
No Matches
Start.h
Go to the documentation of this file.
1
/** @noop License Comment
2
* @file
3
* @copyright
4
* This Source Code is subject to the terms of the Mozilla Public License, v2.0.
5
* If a copy of the MPL was not distributed with this file You can obtain one at
6
* https://mozilla.org/MPL/2.0/
7
*
8
* @author David Mórász
9
* @date 2025
10
*/
11
12
/**
13
* @file
14
* @brief
15
* Use this header and `End.h` in tandem to include third-party library headers which may not tolerate Unreal's common
16
* vocabulary macros or its stricter warning policies.
17
*
18
* With `MCRO_ALLOW_*` macros one can control if a the associated macro should be hidden from the library or not. By
19
* default they're all disallowed (0). For example some COM headers expect `TEXT` to be defined, so one can do
20
* @code
21
* #define MCRO_ALLOW_TEXT 1
22
* #include "Mcro/LibraryIncludes/Start.h"
23
* #include "comdef.h"
24
* #include "Mcro/LibraryIncludes/End.h"
25
* @endcode
26
*
27
* Similarly platform specific include guards like `AllowWindowsPlatformTypes` and `AllowWindowsPlatformAtomics` can
28
* be controlled with `MCRO_ALLOW_<platform>_TYPES` macro. These are allowed by default (1).
29
*
30
* In most cases these 'allow' macros are not needed. Only use them when the wrapped library headers cause compile error
31
* for a missing macro they expected or if 'platform-types' interfere with them. The meaning of these macros are reset
32
* to their default after each inclusion of `End.h`
33
*/
34
35
#include "
Mcro/Macros.h
"
36
37
#ifndef MCRO_ALLOW_WINDOWS_TYPES
38
#define MCRO_ALLOW_WINDOWS_TYPES 1
39
#endif
40
41
#ifndef MCRO_ALLOW_TEXT
42
#define MCRO_ALLOW_TEXT 0
43
#endif
44
#ifndef MCRO_ALLOW_TRUE
45
#define MCRO_ALLOW_TRUE 0
46
#endif
47
#ifndef MCRO_ALLOW_FALSE
48
#define MCRO_ALLOW_FALSE 0
49
#endif
50
#ifndef MCRO_ALLOW_MAX_uint8
51
#define MCRO_ALLOW_MAX_uint8 0
52
#endif
53
#ifndef MCRO_ALLOW_MAX_uint16
54
#define MCRO_ALLOW_MAX_uint16 0
55
#endif
56
#ifndef MCRO_ALLOW_MAX_uint32
57
#define MCRO_ALLOW_MAX_uint32 0
58
#endif
59
#ifndef MCRO_ALLOW_MAX_int32
60
#define MCRO_ALLOW_MAX_int32 0
61
#endif
62
#ifndef MCRO_ALLOW_CONSTEXPR
63
#define MCRO_ALLOW_CONSTEXPR 0
64
#endif
65
#ifndef MCRO_ALLOW_PI
66
#define MCRO_ALLOW_PI 0
67
#endif
68
#ifndef MCRO_ALLOW_dynamic_cast
69
#define MCRO_ALLOW_dynamic_cast 0
70
#endif
71
#ifndef MCRO_ALLOW_VARARGS
72
#define MCRO_ALLOW_VARARGS 0
73
#endif
74
#ifndef MCRO_ALLOW_CDECL
75
#define MCRO_ALLOW_CDECL 0
76
#endif
77
#ifndef MCRO_ALLOW_STDCALL
78
#define MCRO_ALLOW_STDCALL 0
79
#endif
80
#ifndef MCRO_ALLOW_FORCEINLINE
81
#define MCRO_ALLOW_FORCEINLINE 0
82
#endif
83
#ifndef MCRO_ALLOW_FORCENOINLINE
84
#define MCRO_ALLOW_FORCENOINLINE 0
85
#endif
86
#ifndef MCRO_ALLOW_ABSTRACT
87
#define MCRO_ALLOW_ABSTRACT 0
88
#endif
89
#ifndef MCRO_ALLOW_LINE_TERMINATOR
90
#define MCRO_ALLOW_LINE_TERMINATOR 0
91
#endif
92
#ifndef MCRO_ALLOW_LINE_TERMINATOR_ANSI
93
#define MCRO_ALLOW_LINE_TERMINATOR_ANSI 0
94
#endif
95
#ifndef MCRO_ALLOW_DLLEXPORT
96
#define MCRO_ALLOW_DLLEXPORT 0
97
#endif
98
#ifndef MCRO_ALLOW_DLLIMPORT
99
#define MCRO_ALLOW_DLLIMPORT 0
100
#endif
101
#ifndef MCRO_ALLOW_LIKELY
102
#define MCRO_ALLOW_LIKELY 0
103
#endif
104
#ifndef MCRO_ALLOW_UNLIKELY
105
#define MCRO_ALLOW_UNLIKELY 0
106
#endif
107
#ifndef MCRO_ALLOW_RESTRICT
108
#define MCRO_ALLOW_RESTRICT 0
109
#endif
110
#ifndef MCRO_ALLOW_MOBILE
111
#define MCRO_ALLOW_MOBILE 0
112
#endif
113
#ifndef MCRO_ALLOW_CONSOLE
114
#define MCRO_ALLOW_CONSOLE 0
115
#endif
116
#ifndef MCRO_ALLOW_DEFAULTS
117
#define MCRO_ALLOW_DEFAULTS 0
118
#endif
119
120
#ifdef NON_UNREAL_INCLUDE_REGION
121
#error Third-party library or non-unreal include regions cannot be nested, one region is already opened before
122
#endif
123
#define NON_UNREAL_INCLUDE_REGION 1
124
125
#pragma warning( push )
126
#pragma warning( disable : 4005 5205 4265 4268 4946 4103 )
127
128
// temporarily undefine simplistic Unreal macros third-party libraries might also use
129
130
#if !MCRO_ALLOW_TEXT
131
#pragma push_macro("TEXT")
132
#undef TEXT
133
#endif
134
#if !MCRO_ALLOW_TRUE
135
#pragma push_macro("TRUE")
136
#undef TRUE
137
#endif
138
#if !MCRO_ALLOW_FALSE
139
#pragma push_macro("FALSE")
140
#undef FALSE
141
#endif
142
#if !MCRO_ALLOW_MAX_uint8
143
#pragma push_macro("MAX_uint8")
144
#undef MAX_uint8
145
#endif
146
#if !MCRO_ALLOW_MAX_uint16
147
#pragma push_macro("MAX_uint16")
148
#undef MAX_uint16
149
#endif
150
#if !MCRO_ALLOW_MAX_uint32
151
#pragma push_macro("MAX_uint32")
152
#undef MAX_uint32
153
#endif
154
#if !MCRO_ALLOW_MAX_int32
155
#pragma push_macro("MAX_int32")
156
#undef MAX_int32
157
#endif
158
#if !MCRO_ALLOW_CONSTEXPR
159
#pragma push_macro("CONSTEXPR")
160
#undef CONSTEXPR
161
#endif
162
#if !MCRO_ALLOW_PI
163
#pragma push_macro("PI")
164
#undef PI
165
#endif
166
#if !MCRO_ALLOW_dynamic_cast
167
#pragma push_macro("dynamic_cast")
168
#undef dynamic_cast
169
#endif
170
#if !MCRO_ALLOW_VARARGS
171
#pragma push_macro("VARARGS")
172
#undef VARARGS
173
#endif
174
#if !MCRO_ALLOW_CDECL
175
#pragma push_macro("CDECL")
176
#undef CDECL
177
#endif
178
#if !MCRO_ALLOW_STDCALL
179
#pragma push_macro("STDCALL")
180
#undef STDCALL
181
#endif
182
#if !MCRO_ALLOW_FORCEINLINE
183
#pragma push_macro("FORCEINLINE")
184
#undef FORCEINLINE
185
#endif
186
#if !MCRO_ALLOW_FORCENOINLINE
187
#pragma push_macro("FORCENOINLINE")
188
#undef FORCENOINLINE
189
#endif
190
#if !MCRO_ALLOW_ABSTRACT
191
#pragma push_macro("ABSTRACT")
192
#undef ABSTRACT
193
#endif
194
#if !MCRO_ALLOW_LINE_TERMINATOR
195
#pragma push_macro("LINE_TERMINATOR")
196
#undef LINE_TERMINATOR
197
#endif
198
#if !MCRO_ALLOW_LINE_TERMINATOR_ANSI
199
#pragma push_macro("LINE_TERMINATOR_ANSI")
200
#undef LINE_TERMINATOR_ANSI
201
#endif
202
#if !MCRO_ALLOW_DLLEXPORT
203
#pragma push_macro("DLLEXPORT")
204
#undef DLLEXPORT
205
#endif
206
#if !MCRO_ALLOW_DLLIMPORT
207
#pragma push_macro("DLLIMPORT")
208
#undef DLLIMPORT
209
#endif
210
#if !MCRO_ALLOW_LIKELY
211
#pragma push_macro("LIKELY")
212
#undef LIKELY
213
#endif
214
#if !MCRO_ALLOW_UNLIKELY
215
#pragma push_macro("UNLIKELY")
216
#undef UNLIKELY
217
#endif
218
#if !MCRO_ALLOW_RESTRICT
219
#pragma push_macro("RESTRICT")
220
#undef RESTRICT
221
#endif
222
#if !MCRO_ALLOW_MOBILE
223
#pragma push_macro("MOBILE")
224
#undef MOBILE
225
#endif
226
#if !MCRO_ALLOW_CONSOLE
227
#pragma push_macro("CONSOLE")
228
#undef CONSOLE
229
#endif
230
#if !MCRO_ALLOW_DEFAULTS
231
#pragma push_macro("DEFAULTS")
232
#undef DEFAULTS
233
#endif
234
235
#if DO_CHECK
236
#define NUIR_DO_CHECK 1
237
238
#pragma push_macro("DO_CHECK")
239
#pragma push_macro("checkCode")
240
#pragma push_macro("check")
241
#pragma push_macro("checkf")
242
#pragma push_macro("verify")
243
#pragma push_macro("verifyf")
244
#pragma push_macro("unimplemented")
245
#pragma push_macro("ensure")
246
247
#undef DO_CHECK
248
#undef checkCode
249
#undef check
250
#undef checkf
251
#undef verify
252
#undef verifyf
253
#undef unimplemented
254
#undef ensure
255
256
#endif
257
258
#if PLATFORM_WINDOWS && MCRO_ALLOW_WINDOWS_TYPES
259
#include "Windows/AllowWindowsPlatformTypes.h"
260
#include "Windows/AllowWindowsPlatformAtomics.h"
261
#endif
262
263
// A combination of compiler specific macros may be present, which is super rare probably. Third-party libraries might
264
// not tolerate that well. Sanitizing such macros here:
265
266
// prefer MSVC compiler macros over GCC if they're both present for some godforsaken reason
267
#if defined(_MSC_VER) && defined(__GNUC__)
268
269
#if _MSC_VER > 0
270
#pragma message ("Non-Unreal include region: _MSC_VER - __GNUC__ macro collision detected, temporarily undefining __GNUC__ (GCC: " PREPROCESSOR_TO_STRING(__GNUC__) ", MSVC: " PREPROCESSOR_TO_STRING(_MSC_VER) ")")
271
#define NUIR_MSVC_GNUC_AVOIDANCE __GNUC__
272
#pragma push_macro("__GNUC__")
273
#undef __GNUC__
274
#endif
275
276
#endif
277
278
THIRD_PARTY_INCLUDES_START
279
// PRAGMA_PUSH_PLATFORM_DEFAULT_PACKING
Macros.h
Mcro
Public
Mcro
LibraryIncludes
Start.h
Generated by
1.12.0