UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
ApplePlatformCompilerPreSetup.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5// Make certain warnings always be warnings, even despite -Werror.
6// Rationale: we don't want to suppress those as there are plans to address them (e.g. UE-12341), but breaking builds due to these warnings is very expensive
7// since they cannot be caught by all compilers that we support. They are deemed to be relatively safe to be ignored, at least until all SDKs/toolchains start supporting them.
8#ifdef __BUILDING_WITH_FASTBUILD__
9 #pragma clang diagnostic ignored "-Wparentheses-equality"
10#else
11 #pragma clang diagnostic warning "-Wparentheses-equality"
12#endif
13#pragma clang diagnostic ignored "-Winconsistent-missing-override"
14#pragma clang diagnostic ignored "-Wundefined-bool-conversion"
15#pragma clang diagnostic ignored "-Wunused-local-typedef"
16#pragma clang diagnostic ignored "-Wconstant-logical-operand"
17#pragma clang diagnostic ignored "-Wreserved-user-defined-literal"
18#pragma clang diagnostic ignored "-Wdelete-non-virtual-dtor"
19#pragma clang diagnostic ignored "-Wlogical-op-parentheses"
20#pragma clang diagnostic ignored "-Wunused-variable"
21#pragma clang diagnostic ignored "-Wunused-value"
22#pragma clang diagnostic ignored "-Wunused-function" // This will hide the warnings about static functions in headers that aren't used in every single .cpp file
23#pragma clang diagnostic ignored "-Wswitch" // This hides the "enumeration value 'XXXXX' not handled in switch [-Wswitch]" warnings - we should maybe remove this at some point and add UE_LOG(, Fatal, ) to default cases
24#pragma clang diagnostic ignored "-Wtautological-compare" // This hides the "warning : comparison of unsigned expression < 0 is always false" type warnings due to constant comparisons, which are possible with template arguments
25#pragma clang diagnostic ignored "-Wunused-private-field" // This will prevent the issue of warnings for unused private variables.
26#pragma clang diagnostic ignored "-Winvalid-offsetof" // needed to suppress warnings about using offsetof on non-POD types.
27#pragma clang diagnostic ignored "-Wgnu-string-literal-operator-template" // we use this feature to allow static FNames.
28#pragma clang diagnostic ignored "-Wdeprecated-register" // Needed for Alembic third party lib
29#pragma clang diagnostic ignored "-Winconsistent-missing-override" // too many missing overrides...
30#pragma clang diagnostic ignored "-Wunused-local-typedef" // PhysX has some, hard to remove
31#pragma clang diagnostic ignored "-Wlogical-op-parentheses"
32#pragma clang diagnostic ignored "-Wunknown-pragmas"
33#pragma clang diagnostic ignored "-Wundefined-var-template"
34
35#if __has_warning("-Wunused-but-set-variable")
36#pragma clang diagnostic ignored "-Wunused-but-set-variable"
37#endif
38
39// Apple LLVM 9.1.0 (Xcode 9.3)
40#if (__clang_major__ > 9) || (__clang_major__ == 9 && __clang_minor__ >= 1)
41#pragma clang diagnostic ignored "-Wunused-lambda-capture"
42#endif
43
44// Apple LLVM 9.0 (Xcode 9.0)
45#if (__clang_major__ >= 9)
46#pragma clang diagnostic ignored "-Wunguarded-availability-new"
47#endif
48
49// Apple LLVM 8.1.0 (Xcode 8.3) introduced -Wundefined-var-template
50#if (__clang_major__ > 8) || (__clang_major__ == 8 && __clang_minor__ >= 1)
51#pragma clang diagnostic ignored "-Wundefined-var-template"
52#pragma clang diagnostic ignored "-Wnullability-inferred-on-nested-type"
53#pragma clang diagnostic ignored "-Wobjc-protocol-property-synthesis"
54#pragma clang diagnostic ignored "-Wnullability-completeness-on-arrays"
55#pragma clang diagnostic ignored "-Wnull-dereference"
56#pragma clang diagnostic ignored "-Wnullability-completeness" // We are not interoperable with Swift so we DON'T care about nullability qualifiers
57#pragma clang diagnostic ignored "-Wnonportable-include-path" // Ideally this one would be set in MacToolChain, but we don't have a way to check the compiler version in there yet
58#endif
59
60#if (__clang_major__ > 8)
61#pragma clang diagnostic ignored "-Wunguarded-availability-new"
62#endif
63
64// We can use pragma optimisation's on and off as of Apple LLVM 7.3.0 but not before.
65#if (__clang_major__ > 7) || (__clang_major__ == 7 && __clang_minor__ >= 3)
66#define PRAGMA_DISABLE_OPTIMIZATION_ACTUAL _Pragma("clang optimize off")
67#define PRAGMA_ENABLE_OPTIMIZATION_ACTUAL _Pragma("clang optimize on")
68#endif
69
70#define PRAGMA_DEFAULT_VISIBILITY_START _Pragma("GCC visibility push(default)")
71#define PRAGMA_DEFAULT_VISIBILITY_END _Pragma("GCC visibility pop")
72