UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
Platform.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2// IWYU pragma: begin_exports
3#pragma once
4
5#include "Misc/Build.h"
7#include <type_traits>
8
9// define all other platforms to be zero
10//@port Define the platform here to be zero when compiling for other platforms
11#if !defined(PLATFORM_WINDOWS)
12 #define PLATFORM_WINDOWS 0
13#endif
14#if !defined(PLATFORM_MAC)
15 #define PLATFORM_MAC 0
16 // If PLATFORM_MAC is defined these will be set appropriately in
17 // MacPlatform.h
18 #define PLATFORM_MAC_X86 0
19 #define PLATFORM_MAC_ARM64 0
20#endif
21#if !defined(PLATFORM_IOS)
22 #define PLATFORM_IOS 0
23#endif
24#if !defined(UE_PLATFORM_IOS_ONLY)
25 #define UE_PLATFORM_IOS_ONLY 0
26#endif
27#if !defined(PLATFORM_TVOS)
28 #define PLATFORM_TVOS 0
29#endif
30#if !defined(PLATFORM_VISIONOS)
31 #define PLATFORM_VISIONOS 0
32#endif
33#if !defined(PLATFORM_ANDROID)
34 #define PLATFORM_ANDROID 0
35#endif
36#if !defined(PLATFORM_ANDROID_ARM)
37 #define PLATFORM_ANDROID_ARM 0
38#endif
39#if !defined(PLATFORM_ANDROID_ARM64)
40 #define PLATFORM_ANDROID_ARM64 0
41#endif
42#if !defined(PLATFORM_ANDROID_X86)
43 #define PLATFORM_ANDROID_X86 0
44#endif
45#if !defined(PLATFORM_ANDROID_X64)
46 #define PLATFORM_ANDROID_X64 0
47#endif
48#if !defined(PLATFORM_APPLE)
49 #define PLATFORM_APPLE 0
50#endif
51#if !defined(PLATFORM_LINUX)
52 #define PLATFORM_LINUX 0
53#endif
54#if !defined(PLATFORM_LINUXARM64)
55 #define PLATFORM_LINUXARM64 0
56#endif
57#if !defined(PLATFORM_SWITCH)
58 #define PLATFORM_SWITCH 0
59#endif
60#if !defined(PLATFORM_FREEBSD)
61 #define PLATFORM_FREEBSD 0
62#endif
63#if !defined(PLATFORM_UNIX)
64 #define PLATFORM_UNIX 0
65#endif
66#if !defined(PLATFORM_MICROSOFT)
67 #define PLATFORM_MICROSOFT 0
68#endif
69
70// Platform specific compiler pre-setup.
71#include "PreprocessorHelpers.h"
72#include COMPILED_PLATFORM_HEADER(PlatformCompilerPreSetup.h)
73
74// Generic compiler pre-setup.
76
77// Whether the CPU is x86/x64 (i.e. both 32 and 64-bit variants)
78#ifndef PLATFORM_CPU_X86_FAMILY
79 #if (defined(_M_IX86) || defined(__i386__) || defined(_M_X64) || defined(__amd64__) || defined(__x86_64__)) && !defined(_M_ARM64EC)
80 #define PLATFORM_CPU_X86_FAMILY 1
81 #else
82 #define PLATFORM_CPU_X86_FAMILY 0
83 #endif
84#endif
85
86// Whether the CPU is AArch32/AArch64 (i.e. both 32 and 64-bit variants)
87#ifndef PLATFORM_CPU_ARM_FAMILY
88 #if (defined(__arm__) || defined(_M_ARM) || defined(__aarch64__) || defined(_M_ARM64) || defined(_M_ARM64EC))
89 #define PLATFORM_CPU_ARM_FAMILY 1
90 #else
91 #define PLATFORM_CPU_ARM_FAMILY 0
92 #endif
93#endif
94
95// Whether the platform is Arm64ec. Normal Windows Arm64 can be detected with PLATFORM_CPU_ARM_FAMILY && PLATFORM_WINDOWS
96#if defined(_M_ARM64EC)
97 #define PLATFORM_WINDOWS_ARM64EC PLATFORM_WINDOWS
98#else
99 #define PLATFORM_WINDOWS_ARM64EC 0
100#endif
101
102#if PLATFORM_APPLE
103 #include <stddef.h> // needed for size_t
104#endif
105
107
108//------------------------------------------------------------------
109// Setup macros for compiler detection
110//------------------------------------------------------------------
111#ifndef PLATFORM_COMPILER_CLANG
112#if defined(__clang__)
113#define PLATFORM_COMPILER_CLANG 1
114#else
115#define PLATFORM_COMPILER_CLANG 0
116#endif // defined(__clang__)
117#endif
118
119#ifndef PLATFORM_COMPILER_MSVC
120#if defined(_MSC_VER) && !PLATFORM_COMPILER_CLANG
121#define PLATFORM_COMPILER_MSVC 1
122#else
123#define PLATFORM_COMPILER_MSVC 0
124#endif // defined(_MSC_VER) ...
125#endif
126
127//------------------------------------------------------------------
128// Setup macros for static code analysis
129//------------------------------------------------------------------
130#if PLATFORM_COMPILER_CLANG
132#elif PLATFORM_MICROSOFT
134#endif
135
136#ifndef USING_ADDRESS_SANITISER
137 #define USING_ADDRESS_SANITISER 0
138#endif
139
140#ifndef USING_HW_ADDRESS_SANITISER
141 #define USING_HW_ADDRESS_SANITISER 0
142#endif
143
144#ifndef PLATFORM_HAS_ASAN_INCLUDE
145 #define PLATFORM_HAS_ASAN_INCLUDE __has_include(<sanitizer/asan_interface.h>)
146#endif
147
148//---------------------------------------------------------
149// Include main platform setup header (XXX/XXXPlatform.h)
150//---------------------------------------------------------
151
152#include COMPILED_PLATFORM_HEADER(Platform.h)
153
154//------------------------------------------------------------------
155// Finalize define setup
156//------------------------------------------------------------------
157
158// Base defines, must define these for the platform, there are no defaults
159#ifndef PLATFORM_DESKTOP
160 #error "PLATFORM_DESKTOP must be defined"
161#endif
162#ifndef PLATFORM_64BITS
163 #error "PLATFORM_64BITS must be defined"
164#endif
165
166// Base defines, these have defaults
167#ifndef PLATFORM_LITTLE_ENDIAN
168 #define PLATFORM_LITTLE_ENDIAN 0
169#endif
170#ifndef PLATFORM_SUPPORTS_UNALIGNED_LOADS
171 #define PLATFORM_SUPPORTS_UNALIGNED_LOADS 0
172#endif
173#ifndef PLATFORM_EXCEPTIONS_DISABLED
174 #define PLATFORM_EXCEPTIONS_DISABLED !PLATFORM_DESKTOP
175#endif
176#ifndef PLATFORM_SEH_EXCEPTIONS_DISABLED
177 #define PLATFORM_SEH_EXCEPTIONS_DISABLED 0
178#endif
179#ifndef PLATFORM_SUPPORTS_PRAGMA_PACK
180 #define PLATFORM_SUPPORTS_PRAGMA_PACK 0
181#endif
182
183// Defines for the availibility of the various levels of vector intrinsics.
184// These may be set from UnrealBuildTool, otherwise each platform-specific platform.h is expected to set them appropriately.
185#ifndef PLATFORM_ENABLE_VECTORINTRINSICS
186 #define PLATFORM_ENABLE_VECTORINTRINSICS 0
187#endif
188
189// Defines if the platform can handle setting vectorized exception
190// and rounding modes
191#ifndef PLATFORM_SUPPORTS_VECTOR_CONTROL_REGISTERS
192 #define PLATFORM_SUPPORTS_VECTOR_CONTROL_REGISTERS 1
193#endif
194
195#ifndef PLATFORM_USE_SSE2_FOR_THREAD_YIELD
196 #define PLATFORM_USE_SSE2_FOR_THREAD_YIELD PLATFORM_CPU_X86_FAMILY
197#endif
198
199// If PLATFORM_MAYBE_HAS_### is 1, then ### intrinsics are compilable.
200// This does not guarantee that the intrinsics are runnable on all instances of the platform however; a runtime check such as cpuid may be required to confirm availability.
201// If PLATFORM_ALWAYS_HAS_### is 1, then ## intrinsics will compile and run on all instances of the platform. PLATFORM_ALWAYS_HAS_### == 1 implies PLATFORM_MAYBE_HAS_### == 1.
202
203// UE5.2+ requires SSE4.2.
204#ifndef PLATFORM_MAYBE_HAS_SSE4_1
205 #define PLATFORM_MAYBE_HAS_SSE4_1 PLATFORM_CPU_X86_FAMILY
206#endif
207#ifndef PLATFORM_ALWAYS_HAS_SSE4_1
208 #define PLATFORM_ALWAYS_HAS_SSE4_1 PLATFORM_CPU_X86_FAMILY
209#endif
210#ifndef PLATFORM_ALWAYS_HAS_SSE4_2
211 #define PLATFORM_ALWAYS_HAS_SSE4_2 PLATFORM_CPU_X86_FAMILY
212#endif
213
214#ifndef PLATFORM_MAYBE_HAS_AVX
215 #define PLATFORM_MAYBE_HAS_AVX 0
216#endif
217#ifndef PLATFORM_ALWAYS_HAS_AVX
218 #define PLATFORM_ALWAYS_HAS_AVX 0
219#endif
220#ifndef PLATFORM_ALWAYS_HAS_AVX_2
221 #define PLATFORM_ALWAYS_HAS_AVX_2 0
222#endif
223#ifndef PLATFORM_ALWAYS_HAS_FMA3
224 #define PLATFORM_ALWAYS_HAS_FMA3 0
225#endif
226#ifndef PLATFORM_ALWAYS_HAS_AESNI
227 #define PLATFORM_ALWAYS_HAS_AESNI 0
228#endif
229#ifndef PLATFORM_ALWAYS_HAS_SHA
230 #define PLATFORM_ALWAYS_HAS_SHA 0
231#endif
232
233
234#ifndef PLATFORM_HAS_CPUID
235 #if defined(_M_IX86) || defined(__i386__) || defined(_M_X64) || defined(__x86_64__) || defined (__amd64__)
236 #define PLATFORM_HAS_CPUID 1
237 #else
238 #define PLATFORM_HAS_CPUID 0
239 #endif
240#endif
241#ifndef PLATFORM_ENABLE_POPCNT_INTRINSIC
242 // PC is disabled by default, but linux and mac are enabled
243 // if your min spec is an AMD cpu mid-2007 or Intel 2008, you should enable this
244 #define PLATFORM_ENABLE_POPCNT_INTRINSIC 0
245#endif
246#ifndef PLATFORM_ENABLE_VECTORINTRINSICS_NEON
247 #define PLATFORM_ENABLE_VECTORINTRINSICS_NEON 0
248#endif
249#ifndef UE_VALIDATE_FORMAT_STRINGS
250 #define UE_VALIDATE_FORMAT_STRINGS 0
251#endif
252// Does vswprintf want %ls instead of %s when displaying wide strings?
253#ifndef PLATFORM_USE_LS_SPEC_FOR_WIDECHAR
254 #define PLATFORM_USE_LS_SPEC_FOR_WIDECHAR 1
255#endif
256// Does vsprintf want %s instead of %hs when displaying narrow strings?
257#ifndef PLATFORM_USE_S_SPEC_FOR_NARROWCHAR_IN_VSPRINTF
258 #define PLATFORM_USE_S_SPEC_FOR_NARROWCHAR_IN_VSPRINTF 0
259#endif
260#ifndef PLATFORM_USE_SYSTEM_VSWPRINTF
261 #define PLATFORM_USE_SYSTEM_VSWPRINTF 1
262#endif
263#ifndef PLATFORM_COMPILER_DISTINGUISHES_INT_AND_LONG
264 #define PLATFORM_COMPILER_DISTINGUISHES_INT_AND_LONG 0
265#endif
266#ifndef PLATFORM_COMPILER_HAS_GENERIC_KEYWORD
267 #define PLATFORM_COMPILER_HAS_GENERIC_KEYWORD 0
268#endif
269#ifndef PLATFORM_COMPILER_COMMON_LANGUAGE_RUNTIME_COMPILATION
270 #define PLATFORM_COMPILER_COMMON_LANGUAGE_RUNTIME_COMPILATION 0
271#endif
272#ifndef PLATFORM_COMPILER_HAS_TCHAR_WMAIN
273 #define PLATFORM_COMPILER_HAS_TCHAR_WMAIN 0
274#endif
275#ifndef PLATFORM_COMPILER_HAS_GENERATED_COMPARISON_OPERATORS
276 #define PLATFORM_COMPILER_HAS_GENERATED_COMPARISON_OPERATORS (__cplusplus >= 202002L)
277#endif
278// Feature test macro for constexpr __builtin_FILE() and __builtin_LINE()
279#define PLATFORM_COMPILER_SUPPORTS_CONSTEXPR_BUILTIN_FILE_AND_LINE 1 UE_DEPRECATED_MACRO(5.7, "PLATFORM_COMPILER_SUPPORTS_CONSTEXPR_BUILTIN_FILE_AND_LINE has been deprecated and should be replaced with 1.")
280#ifndef PLATFORM_COMPILER_SUPPORTS_BUILTIN_BITCAST
281 #error PLATFORM_COMPILER_SUPPORTS_BUILTIN_BITCAST should have been defined by now
282#endif
283#ifndef PLATFORM_COMPILER_SUPPORTS_CONSTRAINED_DESTRUCTORS
284 // Disable support for constrained destructors on MSVC until this internal compile error gets fixed:
285 //
286 // https://developercommunity.visualstudio.com/t/Internal-compile-error-when-returning-a/10650542
287 #if defined(__cpp_concepts) && __cpp_concepts >= 202002L && (defined(__clang__) || defined(__GNUC__) || !defined(_MSC_VER) || _MSC_VER >= 1942)
288 #define PLATFORM_COMPILER_SUPPORTS_CONSTRAINED_DESTRUCTORS 1
289 #else
290 #define PLATFORM_COMPILER_SUPPORTS_CONSTRAINED_DESTRUCTORS 0
291 #endif
292#endif
293#ifndef PLATFORM_TCHAR_IS_4_BYTES
294 #define PLATFORM_TCHAR_IS_4_BYTES 0
295#endif
296#ifndef PLATFORM_WCHAR_IS_4_BYTES
297 #define PLATFORM_WCHAR_IS_4_BYTES 0
298#endif
299// The PLATFORM_TCHAR_IS_CHAR16 macro really represents PLATFORM_WIDECHAR_IS_CHAR16 - it should be deprecated
300#ifndef PLATFORM_TCHAR_IS_CHAR16
301 #define PLATFORM_TCHAR_IS_CHAR16 0
302#endif
303#define PLATFORM_WIDECHAR_IS_CHAR16 PLATFORM_TCHAR_IS_CHAR16
304#ifndef PLATFORM_TCHAR_IS_UTF8CHAR
305 #define PLATFORM_TCHAR_IS_UTF8CHAR USE_UTF8_TCHARS
306#endif
307#ifndef PLATFORM_UCS2CHAR_IS_UTF16CHAR
308 // Currently true, but we don't want it to be true
309 #define PLATFORM_UCS2CHAR_IS_UTF16CHAR 1
310#endif
311#ifndef PLATFORM_HAS_BSD_TIME
312 #define PLATFORM_HAS_BSD_TIME 1
313#endif
314#ifndef PLATFORM_HAS_BSD_THREAD_CPUTIME
315 #define PLATFORM_HAS_BSD_THREAD_CPUTIME 0
316#endif
317#ifndef PLATFORM_HAS_BSD_SOCKETS
318 #define PLATFORM_HAS_BSD_SOCKETS 1
319#endif
320#ifndef PLATFORM_HAS_BSD_IPV6_SOCKETS
321 #define PLATFORM_HAS_BSD_IPV6_SOCKETS 0
322#endif
323#ifndef PLATFORM_SUPPORTS_UDP_MULTICAST_GROUP
324 #define PLATFORM_SUPPORTS_UDP_MULTICAST_GROUP 1
325#endif
326#ifndef PLATFORM_USE_PTHREADS
327 #define PLATFORM_USE_PTHREADS 1
328#endif
329#ifndef PLATFORM_HAS_MULTITHREADED_PREMAIN
334 #define PLATFORM_HAS_MULTITHREADED_PREMAIN 0
335#endif
336#ifndef PLATFORM_MAX_FILEPATH_LENGTH_DEPRECATED
337 #define PLATFORM_MAX_FILEPATH_LENGTH_DEPRECATED 128 // Deprecated - prefer FPlatformMisc::GetMaxPathLength() instead.
338#endif
339#ifndef PLATFORM_SUPPORTS_TEXTURE_STREAMING
340 #define PLATFORM_SUPPORTS_TEXTURE_STREAMING 1
341#endif
342#ifndef PLATFORM_SUPPORTS_VIRTUAL_TEXTURES
343 #define PLATFORM_SUPPORTS_VIRTUAL_TEXTURES 0
344#endif
345#ifndef PLATFORM_SUPPORTS_VARIABLE_RATE_SHADING
346 #define PLATFORM_SUPPORTS_VARIABLE_RATE_SHADING 0
347#endif
348#ifndef PLATFORM_REQUIRES_FILESERVER
349 #define PLATFORM_REQUIRES_FILESERVER 0
350#endif
351#ifndef PLATFORM_SUPPORTS_MULTITHREADED_GC
352 #define PLATFORM_SUPPORTS_MULTITHREADED_GC 1
353#endif
354#ifndef PLATFORM_HAS_BSD_SOCKET_FEATURE_IOCTL
355 #define PLATFORM_HAS_BSD_SOCKET_FEATURE_IOCTL 1
356#endif
357#ifndef PLATFORM_HAS_BSD_SOCKET_FEATURE_POLL
358 #define PLATFORM_HAS_BSD_SOCKET_FEATURE_POLL 0
359#endif
360#ifndef PLATFORM_HAS_BSD_SOCKET_FEATURE_SELECT
361 #define PLATFORM_HAS_BSD_SOCKET_FEATURE_SELECT 1
362#endif
363#ifndef PLATFORM_HAS_BSD_SOCKET_FEATURE_WINSOCKETS
364 #define PLATFORM_HAS_BSD_SOCKET_FEATURE_WINSOCKETS 0
365#endif
366#ifndef PLATFORM_HAS_BSD_SOCKET_FEATURE_GETHOSTNAME
367 #define PLATFORM_HAS_BSD_SOCKET_FEATURE_GETHOSTNAME 1
368#endif
369#ifndef PLATFORM_HAS_BSD_SOCKET_FEATURE_GETADDRINFO
370 #define PLATFORM_HAS_BSD_SOCKET_FEATURE_GETADDRINFO 1
371#endif
372#ifndef PLATFORM_HAS_BSD_SOCKET_FEATURE_GETNAMEINFO
373 #define PLATFORM_HAS_BSD_SOCKET_FEATURE_GETNAMEINFO 1
374#endif
375#ifndef PLATFORM_HAS_BSD_SOCKET_FEATURE_CLOSE_ON_EXEC
376 #define PLATFORM_HAS_BSD_SOCKET_FEATURE_CLOSE_ON_EXEC 0
377#endif
378#ifndef PLATFORM_HAS_BSD_SOCKET_FEATURE_MSG_DONTWAIT
379 #define PLATFORM_HAS_BSD_SOCKET_FEATURE_MSG_DONTWAIT 0
380#endif
381#ifndef PLATFORM_HAS_BSD_SOCKET_FEATURE_RECVMMSG
382 #define PLATFORM_HAS_BSD_SOCKET_FEATURE_RECVMMSG 0
383#endif
384#ifndef PLATFORM_HAS_BSD_SOCKET_FEATURE_TIMESTAMP
385 #define PLATFORM_HAS_BSD_SOCKET_FEATURE_TIMESTAMP 0
386#endif
387#ifndef PLATFORM_HAS_BSD_SOCKET_FEATURE_NODELAY
388 #define PLATFORM_HAS_BSD_SOCKET_FEATURE_NODELAY 1
389#endif
390#ifndef PLATFORM_HAS_NO_EPROCLIM
391 #define PLATFORM_HAS_NO_EPROCLIM 0
392#endif
393#ifndef PLATFORM_USES_MICROSOFT_LIBC_FUNCTIONS
394 #define PLATFORM_USES_MICROSOFT_LIBC_FUNCTIONS 0
395#endif
396
397#ifndef PLATFORM_USES_GLES
398 #define PLATFORM_USES_GLES 0
399#endif
400
401#ifndef PLATFORM_SUPPORTS_GEOMETRY_SHADERS
402 #define PLATFORM_SUPPORTS_GEOMETRY_SHADERS 1
403#endif
404
405#ifndef PLATFORM_SUPPORTS_MESH_SHADERS
406 #define PLATFORM_SUPPORTS_MESH_SHADERS 0
407#endif
408
409#ifndef PLATFORM_SUPPORTS_WORKGRAPH_SHADERS
410 #define PLATFORM_SUPPORTS_WORKGRAPH_SHADERS 0
411#endif
412
413#ifndef PLATFORM_SUPPORTS_BINDLESS_RENDERING
414 #define PLATFORM_SUPPORTS_BINDLESS_RENDERING 0
415#endif
416
417#ifndef PLATFORM_BUILTIN_VERTEX_HALF_FLOAT
418 #define PLATFORM_BUILTIN_VERTEX_HALF_FLOAT 1
419#endif
420
421#ifndef PLATFORM_SUPPORTS_TBB
422 #define PLATFORM_SUPPORTS_TBB 0
423#endif
424
425#ifndef PLATFORM_SUPPORTS_BORDERLESS_WINDOW
426 #define PLATFORM_SUPPORTS_BORDERLESS_WINDOW 0
427#endif
428
429#ifndef PLATFORM_MAX_CACHED_SYNC_FILE_HANDLES_PER_GENERIC_ASYNC_FILE_HANDLE
430 #define PLATFORM_MAX_CACHED_SYNC_FILE_HANDLES_PER_GENERIC_ASYNC_FILE_HANDLE 4
431#endif
432
433#ifndef PLATFORM_FORCE_SINGLE_SYNC_FILE_HANDLE_PER_GENERIC_ASYNC_FILE_HANDLE
434 #define PLATFORM_FORCE_SINGLE_SYNC_FILE_HANDLE_PER_GENERIC_ASYNC_FILE_HANDLE 0
435#endif
436
437#ifndef PLATFORM_SUPPORTS_JEMALLOC
438 #define PLATFORM_SUPPORTS_JEMALLOC 0
439#endif
440
441#ifndef PLATFORM_SUPPORTS_MIMALLOC
442 #define PLATFORM_SUPPORTS_MIMALLOC 0
443#endif
444
445#ifndef PLATFORM_CAN_SUPPORT_EDITORONLY_DATA
446 #define PLATFORM_CAN_SUPPORT_EDITORONLY_DATA 0
447#endif
448
449#ifndef PLATFORM_SUPPORTS_NAMED_PIPES
450 #define PLATFORM_SUPPORTS_NAMED_PIPES 0
451#endif
452
453#ifndef PLATFORM_USES_FIXED_RHI_CLASS
454 #define PLATFORM_USES_FIXED_RHI_CLASS 0
455#endif
456
457#ifndef PLATFORM_USES_FIXED_GMalloc_CLASS
458 #define PLATFORM_USES_FIXED_GMalloc_CLASS 0
459#endif
460
461#ifndef PLATFORM_USES_STACKBASED_MALLOC_CRASH
462 #define PLATFORM_USES_STACKBASED_MALLOC_CRASH 0
463#endif
464
465#ifndef PLATFORM_SUPPORTS_MULTIPLE_NATIVE_WINDOWS
466 #define PLATFORM_SUPPORTS_MULTIPLE_NATIVE_WINDOWS 1
467#endif
468
469#ifndef PLATFORM_HAS_TOUCH_MAIN_SCREEN
470 #define PLATFORM_HAS_TOUCH_MAIN_SCREEN 0
471#endif
472
473#ifndef PLATFORM_SUPPORTS_STACK_SYMBOLS
474 #define PLATFORM_SUPPORTS_STACK_SYMBOLS 0
475#endif
476
477#ifndef PLATFORM_HAS_128BIT_ATOMICS
478 #define PLATFORM_HAS_128BIT_ATOMICS 0
479#endif
480
481#ifndef PLATFORM_USES_ANSI_STRING_FOR_EXTERNAL_PROFILING
482 #define PLATFORM_USES_ANSI_STRING_FOR_EXTERNAL_PROFILING 1
483#endif
484
485#ifndef PLATFORM_IMPLEMENTS_BeginNamedEventStatic
486 #define PLATFORM_IMPLEMENTS_BeginNamedEventStatic 0
487#endif
488
489#ifndef PLATFORM_HAS_UMA
490 #define PLATFORM_HAS_UMA 0
491#endif
492
493#ifndef PLATFORM_NUM_AUDIODECOMPRESSION_PRECACHE_BUFFERS
494 #define PLATFORM_NUM_AUDIODECOMPRESSION_PRECACHE_BUFFERS 2
495#endif
496
497#ifndef PLATFORM_SUPPORTS_EARLY_MOVIE_PLAYBACK
498 #define PLATFORM_SUPPORTS_EARLY_MOVIE_PLAYBACK 0
499#endif
500
501#ifndef PLATFORM_UI_HAS_MOBILE_SCROLLBARS
502 #define PLATFORM_UI_HAS_MOBILE_SCROLLBARS 0
503#endif
504
505#ifndef PLATFORM_UI_NEEDS_TOOLTIPS
506 #define PLATFORM_UI_NEEDS_TOOLTIPS 1
507#endif
508
509#ifndef PLATFORM_UI_NEEDS_FOCUS_OUTLINES
510 #define PLATFORM_UI_NEEDS_FOCUS_OUTLINES 1
511#endif
512
513#ifndef PLATFORM_LIMIT_MOBILE_BONE_MATRICES
514 #define PLATFORM_LIMIT_MOBILE_BONE_MATRICES 0
515#endif
516
517#ifndef PLATFORM_WEAKLY_CONSISTENT_MEMORY
518 #define PLATFORM_WEAKLY_CONSISTENT_MEMORY PLATFORM_CPU_ARM_FAMILY
519#endif
520
521#ifndef PLATFORM_NEEDS_RHIRESOURCELIST
522 #define PLATFORM_NEEDS_RHIRESOURCELIST 1
523#endif
524
525#ifndef PLATFORM_USE_FULL_TASK_GRAPH
526 #define PLATFORM_USE_FULL_TASK_GRAPH 1
527#endif
528
529#ifndef PLATFORM_USE_ANSI_POSIX_MALLOC
530 #define PLATFORM_USE_ANSI_POSIX_MALLOC 0
531#endif
532
533#ifndef PLATFORM_USES__ALIGNED_MALLOC
534 #define PLATFORM_USES__ALIGNED_MALLOC 0
535#endif
536
537#ifndef PLATFORM_USE_ANSI_MEMALIGN
538 #define PLATFORM_USE_ANSI_MEMALIGN 0
539#endif
540
541#ifndef PLATFORM_IS_ANSI_MALLOC_THREADSAFE
542 #define PLATFORM_IS_ANSI_MALLOC_THREADSAFE 0
543#endif
544
545#ifndef PLATFORM_SUPPORTS_ASYMMETRIC_FENCES
546 #define PLATFORM_SUPPORTS_ASYMMETRIC_FENCES 0
547#endif
548
549#ifndef PLATFORM_SUPPORTS_OPUS_CODEC
550 #define PLATFORM_SUPPORTS_OPUS_CODEC 1
551#endif
552
553#ifndef PLATFORM_SUPPORTS_VORBIS_CODEC
554 #define PLATFORM_SUPPORTS_VORBIS_CODEC 1
555#endif
556
557#ifndef PLATFORM_SUPPORTS_VORBIS_ENCODE
558 #define PLATFORM_SUPPORTS_VORBIS_ENCODE PLATFORM_SUPPORTS_VORBIS_CODEC
559#endif
560
561#ifndef PLATFORM_USE_MINIMAL_HANG_DETECTION
562 #define PLATFORM_USE_MINIMAL_HANG_DETECTION 0
563#endif
564
565#ifndef PLATFORM_USE_GENERIC_STRING_IMPLEMENTATION
566 #define PLATFORM_USE_GENERIC_STRING_IMPLEMENTATION 1
567#endif
568
569#ifndef PLATFORM_ALLOW_ALLOCATIONS_IN_FASYNCWRITER_SERIALIZEBUFFERTOARCHIVE
570 #define PLATFORM_ALLOW_ALLOCATIONS_IN_FASYNCWRITER_SERIALIZEBUFFERTOARCHIVE 1
571#endif
572
573#ifndef PLATFORM_HAS_FPlatformVirtualMemoryBlock
574 #define PLATFORM_HAS_FPlatformVirtualMemoryBlock 1
575#endif
576
577#ifndef PLATFORM_BYPASS_PAK_PRECACHE
578 #define PLATFORM_BYPASS_PAK_PRECACHE 0
579#endif
580
581#ifndef PLATFORM_SUPPORTS_FLIP_TRACKING
582 #define PLATFORM_SUPPORTS_FLIP_TRACKING 0
583#endif
584
585#ifndef PLATFORM_USE_SHOWFLAGS_ALWAYS_BITFIELD
586 #define PLATFORM_USE_SHOWFLAGS_ALWAYS_BITFIELD 1
587#endif
588
589#ifndef PLATFORM_USE_GENERIC_LAUNCH_IMPLEMENTATION
590 #define PLATFORM_USE_GENERIC_LAUNCH_IMPLEMENTATION 0
591#endif
592
593#ifndef PLATFORM_USES_FIXED_HDR_SETTING
594 #define PLATFORM_USES_FIXED_HDR_SETTING 0
595#endif
596
597#ifndef PLATFORM_MANAGES_HDR_SETTING
598 #define PLATFORM_MANAGES_HDR_SETTING 0
599#endif
600
601#ifndef PLATFORM_SUPPORTS_COLORIZED_OUTPUT_DEVICE
602 #define PLATFORM_SUPPORTS_COLORIZED_OUTPUT_DEVICE PLATFORM_DESKTOP
603#endif
604
605#ifndef PLATFORM_USE_PLATFORM_FILE_MANAGED_STORAGE_WRAPPER
606 #define PLATFORM_USE_PLATFORM_FILE_MANAGED_STORAGE_WRAPPER 0
607#endif
608
609#ifndef PLATFORM_HAS_DIRECT_TEXTURE_MEMORY_ACCESS
610 #define PLATFORM_HAS_DIRECT_TEXTURE_MEMORY_ACCESS 0
611#endif
612
613#ifndef PLATFORM_DIRECT_TEXTURE_MEMORY_ACCESS_LOCK_MODE
614 #define PLATFORM_DIRECT_TEXTURE_MEMORY_ACCESS_LOCK_MODE RLM_ReadOnly
615#endif
616
617#ifndef PLATFORM_USE_REPORT_ENSURE
618 #define PLATFORM_USE_REPORT_ENSURE PLATFORM_DESKTOP
619#endif
620
621#ifndef PLATFORM_USE_FALLBACK_PSO
622 #define PLATFORM_USE_FALLBACK_PSO 0
623#endif
624
625#ifndef PLATFORM_SUPPORTS_PSO_PRECACHING
626 #define PLATFORM_SUPPORTS_PSO_PRECACHING (!UE_SERVER)
627#endif
628
629#ifndef PLATFORM_SUPPORTS_DYNAMIC_SHADER_PRELOADING
630#define PLATFORM_SUPPORTS_DYNAMIC_SHADER_PRELOADING (!UE_SERVER)
631#endif
632
633#ifndef PLATFORM_USES_UNFAIR_LOCKS
634 #define PLATFORM_USES_UNFAIR_LOCKS 0
635#endif
636
637#ifndef PLATFORM_HAS_FENV_H
638 #define PLATFORM_HAS_FENV_H 1
639#endif
640
641#ifndef PLATFORM_REQUIRES_TYPELESS_RESOURCE_DISCARD_WORKAROUND
642 #define PLATFORM_REQUIRES_TYPELESS_RESOURCE_DISCARD_WORKAROUND 0
643#endif
644
645#ifndef PLATFORM_CONSOLE_DYNAMIC_LINK
646 #define PLATFORM_CONSOLE_DYNAMIC_LINK 0
647#endif
648
649#ifndef PLATFORM_MAX_UNIFORM_BUFFER_RANGE
650 #define PLATFORM_MAX_UNIFORM_BUFFER_RANGE (16u*1024u)
651#endif
652
653#ifndef PLATFORM_IMPLEMENTS_BATCH_FILE_DELETE
654 #define PLATFORM_IMPLEMENTS_BATCH_FILE_DELETE 0
655#endif
656
657#ifndef PLATFORM_WRITES_ARE_SLOW
658 #define PLATFORM_WRITES_ARE_SLOW 0
659#endif
660
661#ifndef PLATFORM_FORCE_UE_LOCK_USAGE
662 #define PLATFORM_FORCE_UE_LOCK_USAGE 0
663#endif
664
665#ifndef PLATFORM_BREAK_IS_EXPRESSION
666 #define PLATFORM_BREAK_IS_EXPRESSION 0
667#endif
668
669// deprecated, do not use
670#define PLATFORM_HAS_THREADSAFE_RHIGetRenderQueryResult #
671#define PLATFORM_SUPPORTS_RHI_THREAD #
672#define PLATFORM_RHI_USES_CONTEXT_OBJECT # // deprecated, do not use; all platforms must use a context object
673#define PLATFORM_SUPPORTS_PARALLEL_RHI_EXECUTE # // deprecated, do not use; see GRHISupportsParallelRHIExecute
674
675
676//These are deprecated old defines that we want to make sure are not used
677#define CONSOLE (#)
678#define MOBILE (#)
679#define PLATFORM_CONSOLE (#)
680
681// These is computed, not predefined
682#define PLATFORM_32BITS (!PLATFORM_64BITS)
683#if !PLATFORM_64BITS
684 #error "UE only supports 64-bit platforms"
685#endif
686
687// not supported by the platform system yet or maybe ever
688#define PLATFORM_VTABLE_AT_END_OF_CLASS 0
689
690#ifndef VARARGS
691 #define VARARGS /* Functions with variable arguments */
692#endif
693#ifndef CDECL
694 #define CDECL /* Standard C function */
695#endif
696#ifndef STDCALL
697 #define STDCALL /* Standard calling convention */
698#endif
699#ifndef FORCEINLINE
700 #define FORCEINLINE /* Force code to be inline */
701#endif
702#ifndef FORCENOINLINE
703 #define FORCENOINLINE /* Force code to NOT be inline */
704#endif
705#ifndef RESTRICT
706 #define RESTRICT __restrict /* no alias hint */
707#endif
708#ifndef CALLSITE_FORCEINLINE
709 #define CALLSITE_FORCEINLINE /* Force code to be inline at the callsite */
710#endif
711#ifndef UE_DEFINE_FORCEINLINE_HINT_TO_INLINE
712 #define UE_DEFINE_FORCEINLINE_HINT_TO_INLINE 0
713#endif
714
715// A configurable alternative to FORCEINLINE than can be configured per target.
716// The main use of this is for core functionality that is performance sensitive but has a large code size cost.
717// This allows keeping code force inlined by default to improve performance in cases where it wouldn't normally be inlined,
718// but also allow disabling it for targets where the compiler can make more informed decisions such as when using PGO.
719// This ultimately should result in a better size/speed trade off in those cases.
720#if UE_DEFINE_FORCEINLINE_HINT_TO_INLINE
721 #define UE_FORCEINLINE_HINT inline
722#else
723 #define UE_FORCEINLINE_HINT FORCEINLINE
724#endif
725
726// UE_REWRITE should be placed on functions which rewrite a function call as another expression. Like a macro,
727// but without using the preprocessor.
728//
729// Its intent is different from FORCEINLINE, which can be used for optimization reasons. UE_REWRITE should be applied
730// to functions which need to exist for API reasons, but where we don't want any interactions with the user experience,
731// like being forced to step through them in the debugger, or having symbols generated for them.
732//
733// Having a dedicated macro for this specific use case, separate from FORCEINLINE, makes it easier to reason about
734// and spot when it's being misapplied. As a rule of thumb, a rewrite function should consist of a single return statement
735// with at most one call to a non-rewrite function.
736//
737// Examples:
738// - Forwarding calls.
739// - Trivial getters.
740// - Iterators.
741// - Related overloads implemented in terms of each other, like const/non-const, lvalue/rvalue, operator==/operator!=.
742// - Lvalue/rvalue overloads where one is implemented in terms of the other.
743// - Cast functions like MoveTemp, Forward or ImplicitConv.
744// - operator-> on smart pointers.
745// - View constructors.
746#ifndef UE_REWRITE
747 #define UE_REWRITE UE_NODEBUG FORCEINLINE
748#endif
749
750// Use before a constructor declaration to warn when an unnamed temporary object is ignored, e.g. FScopeLock(CS); instead of FScopeLock Lock(CS);
751// We can't just use UE_NODISCARD in this case because older compilers don't like [[nodiscard]] on constructors.
752#if !defined(UE_NODISCARD_CTOR) && defined(__has_cpp_attribute)
753 #if __has_cpp_attribute(nodiscard)
754 #if (defined(_MSC_VER) && _MSC_VER >= 1924) || (defined(__clang__) && __clang_major__ >= 10)
755 #define UE_NODISCARD_CTOR [[nodiscard]]
756 #endif
757 #endif
758#endif
759
760#ifndef UE_NODISCARD_CTOR
761 #define UE_NODISCARD_CTOR
762#endif
763
764/* Use in front of initialized global variable to have link once-semantics
765 When multiple definitions of the variable are encountered by the linker, the first is selected and the remainder are discarded */
766#ifdef _MSC_VER
767 #define UE_SELECT_ANY __declspec(selectany)
768#else
769 #define UE_SELECT_ANY __attribute__((selectany))
770#endif
771
772/* Macro wrapper for the consteval keyword which isn't yet present on all compilers - constexpr
773 can be used as a workaround but is less strict and so may let some non-consteval code pass */
774#if defined(__cpp_consteval)
775 #define UE_CONSTEVAL consteval
776#else
777 #define UE_CONSTEVAL constexpr
778#endif
779
780/* Macro wrapper for the consteval if statement which isn't yet present on all compilers.
781 Can be used in place of std::is_constant_evaluated() which isn't yet available on all platforms. */
782#if defined(__cpp_if_consteval)
783 #define UE_IF_CONSTEVAL if consteval
784 #define UE_IF_NOT_CONSTEVAL if !consteval
785#else
786 #define UE_IF_CONSTEVAL if (__builtin_is_constant_evaluated())
787 #define UE_IF_NOT_CONSTEVAL if (!__builtin_is_constant_evaluated())
788#endif
789
790/* Use before a class data member declaration allow it to be overlapped with other non-static data members or base class subobjects of its class. */
791#if !defined(UE_NO_UNIQUE_ADDRESS) && defined(__has_cpp_attribute)
792 #if __has_cpp_attribute(msvc::no_unique_address)
793 #define UE_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]]
794 #elif __has_cpp_attribute(no_unique_address)
795 #define UE_NO_UNIQUE_ADDRESS [[no_unique_address]]
796 #endif
797#endif
798#ifndef UE_NO_UNIQUE_ADDRESS
799 #define UE_NO_UNIQUE_ADDRESS
800#endif
801
802/* Wrap a function signature in these to indicate that the function never returns nullptr */
803#ifndef FUNCTION_NON_NULL_RETURN_START
804 #define FUNCTION_NON_NULL_RETURN_START
805#endif
806#ifndef FUNCTION_NON_NULL_RETURN_END
807 #define FUNCTION_NON_NULL_RETURN_END
808#endif
809
810/* Wrap lifetimebound annotations to indicate that a function argument must outlive a return value or constructed object */
811#ifndef UE_LIFETIMEBOUND
812 #define UE_LIFETIMEBOUND
813#endif
814
815/* Tag a function or variable to omit debug info for this symbol */
816#ifndef UE_NODEBUG
817 #define UE_NODEBUG
818#endif
819
820/* Annotate functions that allocate new memory to ensure the compiler can optimize them accordingly.
821 The arguments to this macro specify the 1-based arguments of the annotated function that specify the size of the allocation. */
822#ifndef UE_ALLOCATION_FUNCTION
823 #define UE_ALLOCATION_FUNCTION(...)
824#endif
825
827#ifndef UE_ASSUME
828 #if defined(__clang__)
829 #define UE_ASSUME(x) __builtin_assume(x)
830 #elif defined(_MSC_VER)
831 #define UE_ASSUME(x) __assume(x)
832 #else
833 #define UE_ASSUME(x)
834 #endif
835#endif
836
838#ifndef UE_INTRINSIC_CAST
839 #define UE_INTRINSIC_CAST
840#endif
841
843#ifndef LIKELY /* Hints compiler that expression is likely to be true, much softer than UE_ASSUME - allows (penalized by worse performance) expression to be false */
844 #if ( defined(__clang__) || defined(__GNUC__) )
845 #define LIKELY(x) __builtin_expect(!!(x), 1)
846 #else
847 // the additional "!!" is added to silence "warning: equality comparison with exteraneous parenthese" messages on android
848 #define LIKELY(x) (!!(x))
849 #endif
850#endif
851
852#ifndef UNLIKELY /* Hints compiler that expression is unlikely to be true, allows (penalized by worse performance) expression to be true */
853 #if ( defined(__clang__) || defined(__GNUC__) )
854 #define UNLIKELY(x) __builtin_expect(!!(x), 0)
855 #else
856 // the additional "!!" is added to silence "warning: equality comparison with exteraneous parenthese" messages on android
857 #define UNLIKELY(x) (!!(x))
858 #endif
859#endif
860
861// Optimization macros (uses __pragma to enable inside a #define).
862#ifndef PRAGMA_DISABLE_OPTIMIZATION_ACTUAL
863 #define PRAGMA_DISABLE_OPTIMIZATION_ACTUAL
864 #define PRAGMA_ENABLE_OPTIMIZATION_ACTUAL
865#endif
866
867// Disable optimization of a specific function
868#ifndef DISABLE_FUNCTION_OPTIMIZATION
869 #define DISABLE_FUNCTION_OPTIMIZATION
870#endif
871
872// Enable/disable optimizations for a specific function to improve build times
873#define BEGIN_FUNCTION_BUILD_OPTIMIZATION UE_DISABLE_OPTIMIZATION_SHIP
874#define END_FUNCTION_BUILD_OPTIMIZATION UE_ENABLE_OPTIMIZATION_SHIP
875
876#ifndef FORCEINLINE_DEBUGGABLE_ACTUAL
877 #define FORCEINLINE_DEBUGGABLE_ACTUAL inline
878#endif
879
880#ifndef DECLARE_UINT64
881 #define DECLARE_UINT64(x) x##ULL /* Define a 64 bit immediate int **/
882#endif
883
884// Backwater of the spec. All compilers support this except microsoft, and they will soon
885#ifndef TYPENAME_OUTSIDE_TEMPLATE
886 #define TYPENAME_OUTSIDE_TEMPLATE typename
887#endif
888
889// Method modifiers
890#ifndef ABSTRACT
891 #define ABSTRACT
892#endif
893#ifndef IN
894 #define IN
895#endif
896#ifndef OUT
897 #define OUT
898#endif
899
900// String constants
901#ifndef LINE_TERMINATOR
902 #define LINE_TERMINATOR TEXT("\n")
903#endif
904#ifndef LINE_TERMINATOR_ANSI
905 #define LINE_TERMINATOR_ANSI "\n"
906#endif
907
908// Alignment.
909#ifndef GCC_PACK
910 #define GCC_PACK(n)
911#endif
912#ifndef GCC_ALIGN
913 #define GCC_ALIGN(n)
914#endif
915#ifndef MS_ALIGN
916 #define MS_ALIGN(n)
917#endif
918
919// MSVC pragmas - used so other platforms can remove them easily (by not defining this)
920#ifndef MSVC_PRAGMA
921 #define MSVC_PRAGMA(...)
922#endif
923
924
925// Inlining
926#ifndef PRAGMA_DISABLE_INLINING
927 #define PRAGMA_DISABLE_INLINING
928 #define PRAGMA_ENABLE_INLINING
929#endif
930
931// Cache control
932#ifndef FLUSH_CACHE_LINE
933 #define FLUSH_CACHE_LINE(x)
934#endif
935
936// Prefetch
937#ifndef PLATFORM_CACHE_LINE_SIZE
938 #define PLATFORM_CACHE_LINE_SIZE 64
939#endif
940
941// Compile-time warnings and errors. Use these as "#pragma COMPILE_WARNING("XYZ")". GCC does not expand macro parameters to _Pragma, so we can't wrap the #pragma part.
942#ifdef _MSC_VER
943 #define MSC_FORMAT_DIAGNOSTIC_HELPER_2(x) #x
944 #define MSC_FORMAT_DIAGNOSTIC_HELPER(x) MSC_FORMAT_DIAGNOSTIC_HELPER_2(x)
945 #define COMPILE_ERROR(x) __pragma(message(__FILE__ "(" MSC_FORMAT_DIAGNOSTIC_HELPER(__LINE__) "): error: " x))
946 #if UE_WARNINGS_AS_ERRORS
947 #define COMPILE_WARNING(x) COMPILE_ERROR(x)
948 #else
949 #define COMPILE_WARNING(x) __pragma(message(__FILE__ "(" MSC_FORMAT_DIAGNOSTIC_HELPER(__LINE__) "): warning: " x))
950 #endif
951#else
952 #define GCC_DIAGNOSTIC_HELPER(x) _Pragma(#x)
953 #define COMPILE_ERROR(x) GCC_DIAGNOSTIC_HELPER(GCC error x)
954 #if UE_WARNINGS_AS_ERRORS
955 #define COMPILE_WARNING(x) COMPILE_ERROR(x)
956 #else
957 #define COMPILE_WARNING(x) GCC_DIAGNOSTIC_HELPER(GCC warning x)
958 #endif
959#endif
960
961// Tells the compiler to put the decorated function in a certain section (aka. segment) of the executable.
962#ifndef PLATFORM_CODE_SECTION
963 #define PLATFORM_CODE_SECTION(Name)
964#endif
965
966// Mark a function or type as unlikely to be used so the compiler can store it away from the warm code paths & optimize it for size rather than speed.
967// Examples:
968// void UE_COLD HandleError();
969// auto ErrorHandler = []() UE_COLD { abort(); };
970#if !defined(UE_COLD)
971 #if defined(_MSC_VER)
972 #define UE_COLD __declspec(noinline)
973 #elif defined(__GNUC__) || defined(__clang__) || defined(__llvm__)
974 #define UE_COLD __attribute__((cold))
975 #else
976 #define UE_COLD
977 #endif
978#endif
979
980// These have to be forced inline on some OSes so the dynamic loader will not
981// resolve to our allocators for the system libraries.
982#ifndef OPERATOR_NEW_INLINE
983 #define OPERATOR_NEW_INLINE FORCEINLINE
984#endif
985
986#ifndef OPERATOR_NEW_THROW_SPEC
987 #define OPERATOR_NEW_THROW_SPEC
988#endif
989#ifndef OPERATOR_DELETE_THROW_SPEC
990 #define OPERATOR_DELETE_THROW_SPEC
991#endif
992#ifndef OPERATOR_NEW_NOTHROW_SPEC
993 #define OPERATOR_NEW_NOTHROW_SPEC throw()
994#endif
995#ifndef OPERATOR_DELETE_NOTHROW_SPEC
996 #define OPERATOR_DELETE_NOTHROW_SPEC throw()
997#endif
998
999#ifndef checkAtCompileTime
1000 #define checkAtCompileTime(expr, msg) \
1001 EMIT_DEPRECATED_WARNING_MESSAGE("checkAtCompileTime is deprecated. Please use static_assert instead.") \
1002 static_assert(expr, #msg)
1003#endif
1004
1005// DLL export and import definitions
1006#ifndef DLLEXPORT
1007 #define DLLEXPORT
1008 #define DLLIMPORT
1009#endif
1010
1011// embedded app is not default (embedding UE4 in a native view, right now just for IOS and Android)
1012#ifndef BUILD_EMBEDDED_APP
1013 #define BUILD_EMBEDDED_APP 0
1014#endif
1015#ifndef FAST_BOOT_HACKS
1016 #define FAST_BOOT_HACKS 0
1017#endif
1018
1019// Console ANSICHAR/TCHAR command line handling
1020#if PLATFORM_COMPILER_HAS_TCHAR_WMAIN
1021#define INT32_MAIN_INT32_ARGC_TCHAR_ARGV() int32 wmain(int32 ArgC, TCHAR* ArgV[])
1022#else
1023#define INT32_MAIN_INT32_ARGC_TCHAR_ARGV() \
1024int32 tchar_main(int32 ArgC, TCHAR* ArgV[]); \
1025int32 main(int32 ArgC, ANSICHAR* Utf8ArgV[]) \
1026{ \
1027 TCHAR** ArgV = new TCHAR*[ArgC]; \
1028 for (int32 a = 0; a < ArgC; a++) \
1029 { \
1030 FUTF8ToTCHAR ConvertFromUtf8(Utf8ArgV[a]); \
1031 ArgV[a] = new TCHAR[ConvertFromUtf8.Length() + 1]; \
1032 FCString::Strncpy(ArgV[a], ConvertFromUtf8.Get(), ConvertFromUtf8.Length() + 1); \
1033 } \
1034 int32 Result = tchar_main(ArgC, ArgV); \
1035 for (int32 a = 0; a < ArgC; a++) \
1036 { \
1037 delete[] ArgV[a]; \
1038 } \
1039 delete[] ArgV; \
1040 return Result; \
1041} \
1042int32 tchar_main(int32 ArgC, TCHAR* ArgV[])
1043#endif
1044
1045// perform an unaligned write to almost-zero (writing to 0 will throw warnings in some compilers, plus it might actually not crash)
1046// this allow some platforms to change how they force a crash, in case this isn't enough
1047// a platform can likely just #define UE_FORCE_CRASH_AT_OFFSET to override the crash behavior
1048#ifndef UE_FORCE_CRASH_AT_OFFSET
1049 #define UE_FORCE_CRASH_AT_OFFSET(x) *(int32 *)x = 123
1050#endif
1051
1052#ifndef UE_FORCE_CRASH
1053 #define UE_FORCE_CRASH() UE_FORCE_CRASH_AT_OFFSET(3)
1054#endif
1055
1056#ifndef UE_WORKAROUND_CLANG_SVE_LTO_BUGS
1057# define UE_WORKAROUND_CLANG_SVE_LTO_BUGS 0
1058#endif
1059
1060// workaround for LTO generating invalid SVE code that crashes clang
1061#if UE_WORKAROUND_CLANG_SVE_LTO_BUGS
1062# define UE_NO_PROFILE_SVE_BUG UE_NO_PROFILE_ATTRIBUTE
1063#else
1064# define UE_NO_PROFILE_SVE_BUG
1065#endif
1066
1067//--------------------------------------------------------------------------------------------
1068// POD types refactor for porting old code:
1069//
1070// Replace 'FLOAT' with 'float'
1071// Replace 'DOUBLE' with 'double'
1072// Replace 'INT' with 'int32' (make sure not to replace INT text in localization strings!)
1073// Replace 'UINT' with 'uint32'
1074// Replace 'DWORD' with 'uint32' (DWORD is still used in Windows platform source files)
1075// Replace 'WORD' with 'uint16'
1076// Replace 'USHORT' with 'uint16'
1077// Replace 'SWORD' with 'int16'
1078// Replace 'QWORD' with 'uint64'
1079// Replace 'SQWORD' with 'int64'
1080// Replace 'BYTE' with 'uint8'
1081// Replace 'SBYTE' with 'int8'
1082// Replace 'BITFIELD' with 'uint32'
1083// Replace 'UBOOL' with 'bool'
1084// Replace 'FALSE' with 'false' and 'TRUE' with true.
1085// Make sure any platform API uses its own bool types.
1086// For example WinAPI uses BOOL, FALSE and TRUE otherwise sometimes it doesn't work properly
1087// or it doesn't compile.
1088// Replace 'ExtractUBOOLFromBitfield' with 'ExtractBoolFromBitfield'
1089// Replace 'SetUBOOLInBitField' with 'SetBoolInBitField'
1090// Replace 'ParseUBOOL' with 'FParse::Bool'
1091// Replace 'MINBYTE', with 'MIN_uint8'
1092// Replace 'MINWORD', with 'MIN_uint16'
1093// Replace 'MINDWORD', with 'MIN_uint32'
1094// Replace 'MINSBYTE', with 'MIN_int8'
1095// Replace 'MINSWORD', with 'MIN_int16'
1096// Replace 'MAXINT', with 'MAX_int32'
1097// Replace 'MAXBYTE', with 'MAX_uint8'
1098// Replace 'MAXWORD', with 'MAX_uint16'
1099// Replace 'MAXDWORD', with 'MAX_uint32'
1100// Replace 'MAXSBYTE', with 'MAX_int8'
1101// Replace 'MAXSWORD', with 'MAX_int16'
1102// Replace 'MAXINT', with 'MAX_int32'
1103//--------------------------------------------------------------------------------------------
1104
1105//------------------------------------------------------------------
1106// Transfer the platform types to global types
1107//------------------------------------------------------------------
1108
1109//~ Unsigned base types.
1118
1119//~ Signed base types.
1128
1129//~ Character types.
1144
1153
1158
1159//------------------------------------------------------------------
1160// Test the global types
1161//------------------------------------------------------------------
1162namespace TypeTests
1163{
1164 template <typename A, typename B>
1165 inline constexpr bool TAreTypesEqual_V = false;
1166
1167 template <typename T>
1168 inline constexpr bool TAreTypesEqual_V<T, T> = true;
1169
1170#if PLATFORM_TCHAR_IS_4_BYTES
1171 static_assert(sizeof(TCHAR) == 4, "TCHAR size must be 4 bytes.");
1172#elif PLATFORM_TCHAR_IS_UTF8CHAR
1173 static_assert(sizeof(TCHAR) == 1, "TCHAR size must be 1 byte.");
1174#else
1175 static_assert(sizeof(TCHAR) == 2, "TCHAR size must be 2 bytes.");
1176#endif
1177
1178 static_assert(!PLATFORM_WCHAR_IS_4_BYTES || sizeof(wchar_t) == 4, "wchar_t size must be 4 bytes.");
1179 static_assert(PLATFORM_WCHAR_IS_4_BYTES || sizeof(wchar_t) == 2, "wchar_t size must be 2 bytes.");
1180
1181 static_assert(PLATFORM_32BITS || PLATFORM_64BITS, "Type tests pointer size failed.");
1182 static_assert(PLATFORM_32BITS != PLATFORM_64BITS, "Type tests pointer exclusive failed.");
1183 static_assert(!PLATFORM_64BITS || sizeof(void*) == 8, "Pointer size is 64bit, but pointers are short.");
1184 static_assert(PLATFORM_64BITS || sizeof(void*) == 4, "Pointer size is 32bit, but pointers are long.");
1185
1186 static_assert(char(-1) < char(0), "Unsigned char type test failed.");
1187
1188 static_assert((!TAreTypesEqual_V<ANSICHAR, WIDECHAR>), "ANSICHAR and WIDECHAR should be different types.");
1189 static_assert((!TAreTypesEqual_V<ANSICHAR, UTF8CHAR>), "ANSICHAR and UTF8CHAR should be different types.");
1190#if !PLATFORM_UCS2CHAR_IS_UTF16CHAR
1191 // We want these types to be different, because we want to be able to determine whether an encoding
1192 // is fixed-width (UCS2CHAR) or variable-width (UTF16CHAR) at compile time.
1193 static_assert((!TAreTypesEqual_V<UCS2CHAR, UTF16CHAR>), "UCS2CHAR and UTF16CHAR should be different types.");
1194#else
1195 // We don't want these types to be equal, but while this macro exists, they ought to be equal
1196 static_assert(TAreTypesEqual_V<UCS2CHAR, UTF16CHAR>, "UCS2CHAR and UTF16CHAR are expected to be the same type.");
1197#endif
1198 static_assert((!TAreTypesEqual_V<ANSICHAR, UCS2CHAR>), "ANSICHAR and UCS2CHAR should be different types.");
1199 static_assert((!TAreTypesEqual_V<WIDECHAR, UCS2CHAR>), "WIDECHAR and UCS2CHAR should be different types.");
1200 static_assert(TAreTypesEqual_V<TCHAR, ANSICHAR> || TAreTypesEqual_V<TCHAR, WIDECHAR> || TAreTypesEqual_V<TCHAR, UTF8CHAR>, "TCHAR should either be ANSICHAR, WIDECHAR or UTF8CHAR.");
1201
1202#if PLATFORM_WIDECHAR_IS_CHAR16
1203 static_assert(TAreTypesEqual_V<WIDECHAR, char16_t>, "WIDECHAR should be char16_t");
1204#else
1205 static_assert(TAreTypesEqual_V<WIDECHAR, wchar_t>, "WIDECHAR should be wchar_t");
1206#endif
1207
1208 static_assert(sizeof(uint8) == 1, "uint8 type size test failed.");
1209 static_assert(int32(uint8(-1)) == 0xFF, "uint8 type sign test failed.");
1210
1211 static_assert(sizeof(uint16) == 2, "uint16 type size test failed.");
1212 static_assert(int32(uint16(-1)) == 0xFFFF, "uint16 type sign test failed.");
1213
1214 static_assert(sizeof(uint32) == 4, "uint32 type size test failed.");
1215 static_assert(int64(uint32(-1)) == int64(0xFFFFFFFF), "uint32 type sign test failed.");
1216
1217 static_assert(sizeof(uint64) == 8, "uint64 type size test failed.");
1218 static_assert(uint64(-1) > uint64(0), "uint64 type sign test failed.");
1219
1220
1221 static_assert(sizeof(int8) == 1, "int8 type size test failed.");
1222 static_assert(int32(int8(-1)) == -1, "int8 type sign test failed.");
1223
1224 static_assert(sizeof(int16) == 2, "int16 type size test failed.");
1225 static_assert(int32(int16(-1)) == -1, "int16 type sign test failed.");
1226
1227 static_assert(sizeof(int32) == 4, "int32 type size test failed.");
1228 static_assert(int64(int32(-1)) == int64(-1), "int32 type sign test failed.");
1229
1230 static_assert(sizeof(int64) == 8, "int64 type size test failed.");
1231 static_assert(int64(-1) < int64(0), "int64 type sign test failed.");
1232
1233 static_assert(sizeof(ANSICHAR) == 1, "ANSICHAR type size test failed.");
1234 static_assert(int32(ANSICHAR(-1)) == -1, "ANSICHAR type sign test failed.");
1235
1236 static_assert(sizeof(WIDECHAR) == 2 || sizeof(WIDECHAR) == 4, "WIDECHAR type size test failed.");
1237
1238 static_assert(sizeof(UTF8CHAR) == 1, "UTF8CHAR type size test failed.");
1239 static_assert(sizeof(UCS2CHAR) == 2, "UCS2CHAR type size test failed.");
1240 static_assert(sizeof(UTF16CHAR) == 2, "UTF16CHAR type size test failed.");
1241 static_assert(sizeof(UTF32CHAR) == 4, "UTF32CHAR type size test failed.");
1242
1243 static_assert(sizeof(PTRINT) == sizeof(void *), "PTRINT type size test failed.");
1244 static_assert(PTRINT(-1) < PTRINT(0), "PTRINT type sign test failed.");
1245
1246 static_assert(sizeof(UPTRINT) == sizeof(void *), "UPTRINT type size test failed.");
1247 static_assert(UPTRINT(-1) > UPTRINT(0), "UPTRINT type sign test failed.");
1248
1249 static_assert(sizeof(SIZE_T) == sizeof(void *), "SIZE_T type size test failed.");
1250 static_assert(SIZE_T(-1) > SIZE_T(0), "SIZE_T type sign test failed.");
1251}
1252
1253// Platform specific compiler setup.
1254#include COMPILED_PLATFORM_HEADER(PlatformCompilerSetup.h)
1255
1256
1257#define UTF8TEXT_PASTE(x) u8 ## x
1258#define UTF16TEXT_PASTE(x) u ## x
1259#if PLATFORM_WIDECHAR_IS_CHAR16
1260 #define WIDETEXT_PASTE(x) UTF16TEXT_PASTE(x)
1261#else
1262 #define WIDETEXT_PASTE(x) L ## x
1263#endif
1264
1265// If we don't have a platform-specific define for the TEXT macro, define it now.
1266#if !defined(TEXT) && !UE_BUILD_DOCS
1267 #if PLATFORM_TCHAR_IS_UTF8CHAR
1268 #define TEXT_PASTE(x) UTF8TEXT(x)
1269 #else
1270 #define TEXT_PASTE(x) WIDETEXT(x)
1271 #endif
1272 #define TEXT(x) TEXT_PASTE(x)
1273#endif
1274
1275#define UE_UTF8TEXT_IS_CONSTEXPR 1 UE_DEPRECATED_MACRO(5.7, "UE_UTF8TEXT_IS_CONSTEXPR has been deprecated.")
1276
1277namespace UE::Core::Private
1278{
1279 template <typename CharType>
1281 {
1282 static_assert(sizeof(CharType) == 0, "Unsupported char type passed to CHARTEXT");
1283 }
1284}
1285
1286#define UTF8TEXT(x) UTF8TEXT_PASTE(x)
1287#define UTF16TEXT(x) UTF16TEXT_PASTE(x)
1288#define WIDETEXT(str) WIDETEXT_PASTE(str)
1289
1290// Expands out to x, TEXT(x) or UTF8TEXT(x) depending on CharType
1291#define CHARTEXT(CharType, x) \
1292 ( \
1293 []() -> decltype(auto) \
1294 { \
1295 /* We expect <type_traits> to already have been included any time the CHARTEXT macro is used */ \
1296 using UnqualifiedCharType = std::remove_cv_t<CharType>; \
1297 if constexpr (std::is_same_v<UnqualifiedCharType, ANSICHAR>) \
1298 { \
1299 return x; \
1300 } \
1301 else if constexpr (std::is_same_v<UnqualifiedCharType, TCHAR>) \
1302 { \
1303 return TEXT(x); \
1304 } \
1305 else if constexpr (std::is_same_v<UnqualifiedCharType, UTF8CHAR>) \
1306 { \
1307 return UTF8TEXT(x); \
1308 } \
1309 else \
1310 { \
1311 /* We want a compile error, so forward to a templated function because of the static_assert(false) problem */ \
1312 UE::Core::Private::CharTextStaticAssert<CharType>(); \
1313 return x; \
1314 } \
1315 }() \
1316 )
1317
1318// IWYU pragma: end_exports
#define PLATFORM_WCHAR_IS_4_BYTES
Definition AndroidPlatform.h:46
#define PLATFORM_64BITS
Definition ApplePlatform.h:13
FPlatformTypes::CHAR16 UCS2CHAR
A 16-bit character containing a UCS2 (Unicode, 16-bit, fixed-width) code unit, used for compatibility...
Definition Platform.h:1139
FPlatformTypes::int16 int16
A 16-bit signed integer.
Definition Platform.h:1123
FPlatformTypes::int8 int8
An 8-bit signed integer.
Definition Platform.h:1121
FPlatformTypes::SSIZE_T SSIZE_T
An integer the same size as a pointer, the same as PTRINT.
Definition Platform.h:1152
FPlatformTypes::SIZE_T SIZE_T
An unsigned integer the same size as a pointer, the same as UPTRINT.
Definition Platform.h:1150
FPlatformTypes::TYPE_OF_NULLPTR TYPE_OF_NULLPTR
The type of the C++ nullptr keyword.
Definition Platform.h:1157
FPlatformTypes::PTRINT PTRINT
A signed integer the same size as a pointer.
Definition Platform.h:1148
FPlatformTypes::uint8 uint8
An 8-bit unsigned integer.
Definition Platform.h:1111
FPlatformTypes::uint16 uint16
A 16-bit unsigned integer.
Definition Platform.h:1113
#define PLATFORM_32BITS
Definition Platform.h:682
FPlatformTypes::UTF32CHAR UTF32CHAR
A 32-bit character containing a UTF32 (Unicode, 32-bit, fixed-width) code unit.
Definition Platform.h:1143
FPlatformTypes::TCHAR TCHAR
Either ANSICHAR or WIDECHAR, depending on whether the platform supports wide characters or the requir...
Definition Platform.h:1135
FPlatformTypes::WIDECHAR WIDECHAR
A wide character. Normally a signed type.
Definition Platform.h:1133
FPlatformTypes::int64 int64
A 64-bit signed integer.
Definition Platform.h:1127
FPlatformTypes::uint32 uint32
A 32-bit unsigned integer.
Definition Platform.h:1115
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
FPlatformTypes::UPTRINT UPTRINT
An unsigned integer the same size as a pointer.
Definition Platform.h:1146
FPlatformTypes::UTF8CHAR UTF8CHAR
An 8-bit character containing a UTF8 (Unicode, 8-bit, variable-width) code unit.
Definition Platform.h:1137
FPlatformTypes::CHAR16 UTF16CHAR
A 16-bit character containing a UTF16 (Unicode, 16-bit, variable-width) code unit.
Definition Platform.h:1141
FPlatformTypes::ANSICHAR ANSICHAR
An ANSI character. Normally a signed type.
Definition Platform.h:1131
FPlatformTypes::TYPE_OF_NULL TYPE_OF_NULL
The type of the NULL constant.
Definition Platform.h:1155
FPlatformTypes::uint64 uint64
A 64-bit unsigned integer.
Definition Platform.h:1117
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
uint8_t uint8
Definition binka_ue_file_header.h:8
uint16_t uint16
Definition binka_ue_file_header.h:7
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition Platform.h:1163
constexpr bool TAreTypesEqual_V
Definition Platform.h:1165
constexpr bool TAreTypesEqual_V< T, T >
Definition Platform.h:1168
implementation
Definition PlayInEditorLoadingScope.h:8
void CharTextStaticAssert()
Definition Platform.h:1280
WIDECHAR TCHAR
Definition AndroidPlatform.h:25
char16_t WIDECHAR
Definition AndroidPlatform.h:24
unsigned long long uint64
Definition GenericPlatform.h:46
unsigned char uint8
Definition GenericPlatform.h:37
decltype(nullptr) TYPE_OF_NULLPTR
Definition GenericPlatform.h:99
SelectIntPointerType< int32, int64, sizeof(void *)>::TIntPointer PTRINT
Definition GenericPlatform.h:90
char ANSICHAR
Definition GenericPlatform.h:65
signed short int int16
Definition GenericPlatform.h:54
unsigned short int uint16
Definition GenericPlatform.h:40
signed char int8
Definition GenericPlatform.h:51
unsigned int uint32
Definition GenericPlatform.h:43
int32 TYPE_OF_NULL
Definition GenericPlatform.h:98
UPTRINT SIZE_T
Definition GenericPlatform.h:93
SelectIntPointerType< uint32, uint64, sizeof(void *)>::TIntPointer UPTRINT
Definition GenericPlatform.h:87
signed int int32
Definition GenericPlatform.h:57
char32_t UTF32CHAR
Definition GenericPlatform.h:81
PTRINT SSIZE_T
Definition GenericPlatform.h:96
uint16 CHAR16
Definition GenericPlatform.h:74
char8_t UTF8CHAR
Definition GenericPlatform.h:71
signed long long int64
Definition GenericPlatform.h:60