UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
ApplePlatform.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3
4/*=============================================================================================
5 ApplePlatform.h: Common setup for Apple platforms
6==============================================================================================*/
7
8#pragma once
9
10#include "Clang/ClangPlatform.h"
11
12// Base defines, must define these for the platform, there are no defaults
13#define PLATFORM_64BITS 1
14// Technically the underlying platform has 128bit atomics, but clang might not issue optimal code
15#define PLATFORM_HAS_128BIT_ATOMICS 0
16
17// Base defines, defaults are commented out
18#define PLATFORM_LITTLE_ENDIAN 1
19#define PLATFORM_SEH_EXCEPTIONS_DISABLED 1
20#define PLATFORM_SUPPORTS_PRAGMA_PACK 1
21#define PLATFORM_ENABLE_VECTORINTRINSICS 1
22#define PLATFORM_USE_SYSTEM_VSWPRINTF 0
23#define PLATFORM_COMPILER_DISTINGUISHES_INT_AND_LONG 1
24#define PLATFORM_WCHAR_IS_4_BYTES 1
25#define PLATFORM_HAS_BSD_TIME 1
26#define PLATFORM_HAS_BSD_IPV6_SOCKETS 1
27#define PLATFORM_HAS_BSD_SOCKET_FEATURE_MSG_DONTWAIT 1
28#define PLATFORM_HAS_MULTITHREADED_PREMAIN 1
29#define PLATFORM_SUPPORTS_TEXTURE_STREAMING 1
30#define PLATFORM_SUPPORTS_STACK_SYMBOLS 1
31#define PLATFORM_IS_ANSI_MALLOC_THREADSAFE 1
32
33#define PLATFORM_BREAK() __builtin_debugtrap()
34
35#define PLATFORM_CODE_SECTION(Name) __attribute__((section("__TEXT,__" Name ",regular,pure_instructions"))) \
36 __attribute__((aligned(4)))
37
38// Ensure we can use this builtin - seems to be present on Clang 9, GCC 11 and MSVC 19.26,
39// but gives spurious "non-void function 'BitCast' should return a value" errors on some
40// Mac and Android toolchains when building PCHs, so avoid those.
41#undef PLATFORM_COMPILER_SUPPORTS_BUILTIN_BITCAST
42#define PLATFORM_COMPILER_SUPPORTS_BUILTIN_BITCAST (__clang_major__ >= 13)
43
44// Function type macros.
45#define VARARGS /* Functions with variable arguments */
46#define CDECL /* Standard C function */
47#define STDCALL /* Standard calling convention */
48#define FORCENOINLINE __attribute__((noinline)) /* Force code to NOT be inline */
49#define FUNCTION_CHECK_RETURN_END __attribute__ ((warn_unused_result)) /* Warn that callers should not ignore the return value. */
50#define FUNCTION_NO_RETURN_END __attribute__ ((noreturn)) /* Indicate that the function never returns. */
51
52#define ABSTRACT abstract
53
54// We can use pragma optimisations on and off as of Apple LLVM 7.3.0 but not before.
55#if (__clang_major__ > 7) || (__clang_major__ == 7 && __clang_minor__ >= 3)
56# define PRAGMA_DISABLE_OPTIMIZATION_ACTUAL _Pragma("clang optimize off")
57# define PRAGMA_ENABLE_OPTIMIZATION_ACTUAL _Pragma("clang optimize on")
58#endif
59
60// Alignment.
61#define GCC_PACK(n) __attribute__((packed,aligned(n)))
62#define GCC_ALIGN(n) __attribute__((aligned(n)))
63
64// operator new/delete operators
65// As of 10.9 we need to use _NOEXCEPT & cxx_noexcept compatible definitions
66#if __has_feature(cxx_noexcept)
67# define OPERATOR_NEW_THROW_SPEC
68#else
69# define OPERATOR_NEW_THROW_SPEC throw (std::bad_alloc)
70#endif
71#define OPERATOR_DELETE_THROW_SPEC noexcept
72#define OPERATOR_NEW_NOTHROW_SPEC noexcept
73#define OPERATOR_DELETE_NOTHROW_SPEC noexcept
74
75// DLL export and import definitions
76#define DLLEXPORT __attribute__((visibility("default")))
77#define DLLIMPORT __attribute__((visibility("default")))