Overte C++ Documentation
WarningsSuppression.h
1 //
2 // WarningsSuppression.h
3 //
4 //
5 // Created by Dale Glass on 5/6/2022
6 // Copyright 2022 Dale Glass
7 //
8 // Distributed under the Apache License, Version 2.0.
9 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
10 //
11 
12 /*
13  * This file provides macros to suppress compile-time warnings.
14  * They should be used with extreme caution, only when the compiler is definitely mistaken,
15  * when the problem is in third party code that's not practical to patch, or where something
16  * is deprecated but can't be dealt with for the time being.
17  *
18  * Usage of these macros should come with an explanation of why we're using them.
19  */
20 
21 
22 #ifdef OVERTE_WARNINGS_WHITELIST_GCC
23 
24  #define OVERTE_IGNORE_DEPRECATED_BEGIN \
25  _Pragma("GCC diagnostic push") \
26  _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
27 
28  #define OVERTE_IGNORE_DEPRECATED_END _Pragma("GCC diagnostic pop")
29 
30 #elif OVERTE_WARNINGS_WHITELIST_CLANG
31 
32  #define OVERTE_IGNORE_DEPRECATED_BEGIN \
33  _Pragma("clang diagnostic push") \
34  _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
35 
36  #define OVERTE_IGNORE_DEPRECATED_END _Pragma("clang diagnostic pop")
37 
38 #elif OVERTE_WARNINGS_WHITELIST_MSVC
39 
40  #define OVERTE_IGNORE_DEPRECATED_BEGIN \
41  _Pragma("warning(push)") \
42  _Pragma("warning(disable : 4996)")
43 
44  #define OVERTE_IGNORE_DEPRECATED_END _Pragma("warning(pop)")
45 
46 #else
47 
48 #warning "Don't know how to suppress warnings on this compiler. Please fix me."
49 
50 #define OVERTE_IGNORE_DEPRECATED_BEGIN
51 #define OVERTE_IGNORE_DEPRECATED_END
52 
53 #endif