UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
WindowsPlatform.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5// HEADER_UNIT_SKIP - Not included directly
6
7#include <sal.h>
8
9#if defined(__INTEL_LLVM_COMPILER)
11#elif defined(__clang__)
12 #include "Clang/ClangPlatform.h"
13#else
15#endif
16
17#if WINVER <= 0x600
18 #error "Windows Vista and earlier are no longer supported"
19#endif
20
21#ifndef PLATFORM_COMPILER_CLANG
22#if defined(__clang__)
23#define PLATFORM_COMPILER_CLANG 1
24#else
25#define PLATFORM_COMPILER_CLANG 0
26#endif // defined(__clang__)
27#endif
28
29#include "GenericPlatform/GenericPlatform.h" //for FGenericPlatformTypes
30
35{
36#ifdef _WIN64
37 typedef unsigned __int64 SIZE_T;
38 typedef __int64 SSIZE_T;
39#else
40 typedef unsigned long SIZE_T;
41 typedef long SSIZE_T;
42#endif
43
44#if USE_UTF8_TCHARS
45 typedef UTF8CHAR TCHAR;
46#endif
47};
48
50
51// Base defines, must define these for the platform, there are no defaults
52#define PLATFORM_DESKTOP 1
53#if defined( _WIN64 )
54 #define PLATFORM_64BITS 1
55#else
56 #define PLATFORM_64BITS 0
57#endif
58#if defined( _MANAGED ) || defined( _M_CEE )
59 #define PLATFORM_COMPILER_COMMON_LANGUAGE_RUNTIME_COMPILATION 1
60#endif
61#define PLATFORM_CAN_SUPPORT_EDITORONLY_DATA 1
62
63// Base defines, defaults are commented out
64
65#define PLATFORM_LITTLE_ENDIAN 1
66#define PLATFORM_SUPPORTS_UNALIGNED_LOADS 1
67#define PLATFORM_SUPPORTS_FLIP_TRACKING 1
68
69#define PLATFORM_SUPPORTS_PRAGMA_PACK 1
70#if (defined(__arm__) || defined(_M_ARM) || defined(__aarch64__) || defined(_M_ARM64) || defined(_M_ARM64EC))
71 #define PLATFORM_CPU_ARM_FAMILY 1
72 #define PLATFORM_ENABLE_VECTORINTRINSICS_NEON 1
73 #define PLATFORM_ENABLE_VECTORINTRINSICS 1
74#elif (defined(_M_IX86) || defined(_M_X64))
75 #define PLATFORM_CPU_ARM_FAMILY 0
76 #define PLATFORM_CPU_X86_FAMILY 1
77 #define PLATFORM_ENABLE_VECTORINTRINSICS 1
78
79#endif
80// FMA3 support was added starting from AMD Piledriver (excluding Jaguar) and Intel Haswell (excluding Pentium and Celeron)
81#ifndef PLATFORM_ALWAYS_HAS_FMA3
82 #define PLATFORM_ALWAYS_HAS_FMA3 0
83#endif
84
85#define PLATFORM_USE_LS_SPEC_FOR_WIDECHAR 0
86//#define PLATFORM_USE_SYSTEM_VSWPRINTF 1
87//#define PLATFORM_TCHAR_IS_4_BYTES 0
88#define PLATFORM_HAS_BSD_TIME 0
89#define PLATFORM_USE_PTHREADS 0
90#define PLATFORM_USES_UNFAIR_LOCKS 1
91#define PLATFORM_MAX_FILEPATH_LENGTH_DEPRECATED WINDOWS_MAX_PATH
92#define PLATFORM_HAS_BSD_IPV6_SOCKETS 1
93#define PLATFORM_HAS_BSD_SOCKET_FEATURE_WINSOCKETS 1
94#define PLATFORM_USES_MICROSOFT_LIBC_FUNCTIONS 1
95#define PLATFORM_IS_ANSI_MALLOC_THREADSAFE 1
96#define PLATFORM_SUPPORTS_ASYMMETRIC_FENCES 1
97
98#define PLATFORM_SUPPORTS_TBB 1
99#define PLATFORM_SUPPORTS_MIMALLOC PLATFORM_64BITS
100#define PLATFORM_SUPPORTS_NAMED_PIPES 1
101#define PLATFORM_COMPILER_HAS_TCHAR_WMAIN 1
102#define PLATFORM_SUPPORTS_EARLY_MOVIE_PLAYBACK (!WITH_EDITOR) // movies will start before engine is initalized
103#define PLATFORM_USE_GENERIC_STRING_IMPLEMENTATION 0 // Can set this to 1 if you need to debug FGenericWidePlatformString::GetVarArgs on Windows
104#define PLATFORM_SUPPORTS_VARIABLE_RATE_SHADING 1
105#define PLATFORM_SUPPORTS_MESH_SHADERS 1
106#define PLATFORM_SUPPORTS_WORKGRAPH_SHADERS 1
107#define PLATFORM_SUPPORTS_BINDLESS_RENDERING 1
108#define PLATFORM_USES__ALIGNED_MALLOC 1
109
110#if WITH_EDITOR
111#define PLATFORM_FILE_READER_BUFFER_SIZE (256*1024)
112#endif
113
114#define PLATFORM_SUPPORTS_STACK_SYMBOLS 1
115
116#define PLATFORM_GLOBAL_LOG_CATEGORY LogWindows
117
118#define PLATFORM_SUPPORTS_BORDERLESS_WINDOW 1
119
120#if defined(__clang__)
121#define PLATFORM_RETURN_ADDRESS_FOR_CALLSTACKTRACING PLATFORM_RETURN_ADDRESS
122#define PLATFORM_USE_CALLSTACK_ADDRESS_POINTER 0
123#else
124#define PLATFORM_RETURN_ADDRESS_FOR_CALLSTACKTRACING PLATFORM_RETURN_ADDRESS_POINTER
125#define PLATFORM_USE_CALLSTACK_ADDRESS_POINTER 1
126#endif
127
128#define WINDOWS_USE_FEATURE_APPLICATIONMISC_CLASS 1
129#define WINDOWS_USE_FEATURE_PLATFORMMISC_CLASS 1
130#define WINDOWS_USE_FEATURE_PLATFORMHTTP_CLASS 1
131
132
133// Q: Why is there a __nop() before __debugbreak()?
134// A: VS' debug engine has a bug where it will silently swallow explicit
135// breakpoint interrupts when single-step debugging either line-by-line or
136// over call instructions. This can hide legitimate reasons to trap. Asserts
137// for example, which can appear as if the did not fire, leaving a programmer
138// unknowingly debugging an undefined process.
139#define PLATFORM_BREAK() (__nop(), __debugbreak())
140#define PLATFORM_BREAK_IS_EXPRESSION 1
141
142// Intrinsics for 128-bit atomics on Windows platform requires Windows 8 or higher (WINVER>=0x0602)
143// http://msdn.microsoft.com/en-us/library/windows/desktop/hh972640.aspx
144#define PLATFORM_HAS_128BIT_ATOMICS (PLATFORM_64BITS && (WINVER >= 0x602))
145
146#ifdef CDECL
147#undef CDECL
148#endif
149
150// Function type macros.
151#define VARARGS __cdecl /* Functions with variable arguments */
152#define CDECL __cdecl /* Standard C function */
153#define STDCALL __stdcall /* Standard calling convention */
154#define FORCEINLINE __forceinline /* Force code to be inline */
155#define FORCENOINLINE __declspec(noinline) /* Force code to NOT be inline */
156
157// When using clang-cl we will pick up the ClangPlatform.h definition of this macro before this, so check first!
158#ifndef FUNCTION_NON_NULL_RETURN_START
159#define FUNCTION_NON_NULL_RETURN_START _Ret_notnull_ /* Indicate that the function never returns nullptr. */
160#endif
161
162#define DECLARE_UINT64(x) x
163
164// Optimization macros (uses __pragma to enable inside a #define).
165#if !defined(__clang__)
166 #define PRAGMA_DISABLE_OPTIMIZATION_ACTUAL __pragma(optimize("",off))
167 #define PRAGMA_ENABLE_OPTIMIZATION_ACTUAL __pragma(optimize("",on))
168#elif defined(_MSC_VER) // Clang only supports __pragma with -fms-extensions
169 #define PRAGMA_DISABLE_OPTIMIZATION_ACTUAL __pragma(clang optimize off)
170 #define PRAGMA_ENABLE_OPTIMIZATION_ACTUAL __pragma(clang optimize on)
171#endif
172
173#if !defined(__clang__)
174 #define PLATFORM_EMPTY_BASES __declspec(empty_bases)
175#endif
176
177// Tells the compiler to put the decorated function in a certain section (aka. segment) of the executable.
178#define PLATFORM_CODE_SECTION(Name) __declspec(code_seg(Name))
179
180// Backwater of the spec. All compilers support this except microsoft, and they will soon
181#if !defined(__clang__) // Clang expects typename outside template
182 #define TYPENAME_OUTSIDE_TEMPLATE
183#endif
184
185#pragma warning(disable : 4481) // nonstandard extension used: override specifier 'override'
186
187#define ABSTRACT abstract
188
189// Strings.
190#define LINE_TERMINATOR TEXT("\r\n")
191#define LINE_TERMINATOR_ANSI "\r\n"
192
193// Alignment.
194#if defined(__clang__)
195 #define GCC_PACK(n) __attribute__((packed,aligned(n)))
196 #define GCC_ALIGN(n) __attribute__((aligned(n)))
197 #if defined(_MSC_VER)
198 #define MS_ALIGN(n) __declspec(align(n)) // With -fms-extensions, Clang will accept either alignment attribute
199 #endif
200#else
201 #define MS_ALIGN(n) __declspec(align(n))
202#endif
203
204// Pragmas
205#if !defined(__clang__)
206 #define MSVC_PRAGMA(Pragma) __pragma(Pragma)
207#endif
208
209// Prefetch
210#define PLATFORM_CACHE_LINE_SIZE 64
211
212// DLL export and import definitions
213#define DLLEXPORT __declspec(dllexport)
214#define DLLIMPORT __declspec(dllimport)
215
216// disable this now as it is annoying for generic platform implementations
217#pragma warning(disable : 4100) // unreferenced formal parameter
218
219
220// Include code analysis features
221#if PLATFORM_COMPILER_CLANG
223#elif PLATFORM_WINDOWS
225#endif
226
227// Other macros
228#ifndef ENABLE_WIN_ALLOC_TRACKING
229#define ENABLE_WIN_ALLOC_TRACKING 0
230#endif
231
232// If set, ShouldExpectLowIntegrityLevel defaults to true. This affects paths for local settings and storage.
233#ifndef WINDOWS_LOWINTEGRITYLEVEL_EXPECT_DEFAULT
234#define WINDOWS_LOWINTEGRITYLEVEL_EXPECT_DEFAULT 0
235#endif
236
237// If set, the engine will attempt to automatically migrate user data like settings from the default medium integrity ProjectUserDir path to the low integrity one.
238// Migration is only attempted if the low integrity ProjectUserDir path is empty, e.g. first run after a game update that sets WINDOWS_LOWINTEGRITYLEVEL_EXPECT_DEFAULT = 1.
239#ifndef WINDOWS_LOWINTEGRITYLEVEL_AUTOMIGRATE_USERDATA
240#define WINDOWS_LOWINTEGRITYLEVEL_AUTOMIGRATE_USERDATA 0
241#endif
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
FWindowsPlatformTypes FPlatformTypes
Definition WindowsPlatform.h:49
Definition GenericPlatform.h:33
WIDECHAR TCHAR
Definition GenericPlatform.h:84
char8_t UTF8CHAR
Definition GenericPlatform.h:71
Definition WindowsPlatform.h:35
long SSIZE_T
Definition WindowsPlatform.h:41
unsigned long SIZE_T
Definition WindowsPlatform.h:40