HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SYS_Pragma.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: SYS_Pragma.h (SYS Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __SYS_PRAGMA_H_INCLUDED__
12 #define __SYS_PRAGMA_H_INCLUDED__
13 
14 #include "SYS_Compiler.h"
15 
16 /// SYS_PRAGMA allows one to embed multiple into macros
17 #if defined(_MSC_VER)
18 # define SYS_PRAGMA(X) __pragma(X)
19 #elif defined(__GNUC__)
20 # define SYS_PRAGMA(X) _Pragma(#X)
21 #else
22 # define SYS_PRAGMA(X)
23 #endif
24 
25 /// Temporarily disable warnings. The PUSH/POPs must match!
26 /// @note Only implemented for Visual C++ and gcc 4.6
27 #if defined(_MSC_VER)
28 # define SYS_PRAGMA_PUSH_WARN() SYS_PRAGMA(warning(push))
29 # define SYS_PRAGMA_POP_WARN() SYS_PRAGMA(warning(pop))
30 #elif SYS_IS_GCC_GE(4, 6) || defined(__clang__)
31 # define SYS_PRAGMA_PUSH_WARN() SYS_PRAGMA(GCC diagnostic push)
32 # define SYS_PRAGMA_POP_WARN() SYS_PRAGMA(GCC diagnostic pop)
33 #else
34 # define SYS_PRAGMA_PUSH_WARN()
35 # define SYS_PRAGMA_POP_WARN()
36 #endif
37 
38 #if defined(_MSC_VER)
39 # define SYS_PRAGMA_DISABLE_DEPRECATED() \
40  SYS_PRAGMA(warning(disable: 4996))
41 #elif SYS_IS_GCC_GE(4, 2) || defined(__clang__)
42 # define SYS_PRAGMA_DISABLE_DEPRECATED() \
43  SYS_PRAGMA(GCC diagnostic ignored "-Wdeprecated-declarations")
44 #else
45 # define SYS_PRAGMA_DISABLE_DEPRECATED()
46 #endif
47 #if defined(_MSC_VER)
48 # define SYS_PRAGMA_DISABLE_OVERLOADED_VIRTUAL() \
49  SYS_PRAGMA(warning(disable: 4263)) \
50  SYS_PRAGMA(warning(disable: 4266)) \
51  /**/
52 #elif SYS_IS_GCC_GE(4, 6) || defined(__clang__)
53 # define SYS_PRAGMA_DISABLE_OVERLOADED_VIRTUAL() \
54  SYS_PRAGMA(GCC diagnostic ignored "-Woverloaded-virtual")
55 #else
56 # define SYS_PRAGMA_DISABLE_OVERLOADED_VIRTUAL()
57 #endif
58 #if SYS_IS_GCC_GE(4, 6) || defined(__clang__)
59 # define SYS_PRAGMA_DISABLE_IGNORED_QUALIFIERS() \
60  SYS_PRAGMA(GCC diagnostic ignored "-Wignored-qualifiers")
61 #else
62 # define SYS_PRAGMA_DISABLE_IGNORED_QUALIFIERS()
63 #endif
64 #if SYS_IS_GCC_GE(4, 6) || defined(__clang__)
65 # define SYS_PRAGMA_DISABLE_UNUSED_FUNCTION() \
66  SYS_PRAGMA(GCC diagnostic ignored "-Wunused-function")
67 #else
68 # define SYS_PRAGMA_DISABLE_UNUSED_FUNCTION()
69 #endif
70 #if SYS_IS_GCC_GE(4, 6) || defined(__clang__)
71 # define SYS_PRAGMA_DISABLE_UNUSED_VALUE() \
72  SYS_PRAGMA(GCC diagnostic ignored "-Wunused-value")
73 #else
74 # define SYS_PRAGMA_DISABLE_UNUSED_VALUE()
75 #endif
76 #if SYS_IS_GCC_GE(4, 6) || defined(__clang__)
77 # define SYS_PRAGMA_DISABLE_UNUSED_VARIABLE() \
78  SYS_PRAGMA(GCC diagnostic ignored "-Wunused-variable")
79 #else
80 # define SYS_PRAGMA_DISABLE_UNUSED_VARIABLE()
81 #endif
82 #if SYS_IS_GCC_GE(4, 6)
83 # define SYS_PRAGMA_DISABLE_UNUSED_BUT_SET_VARIABLE() \
84  SYS_PRAGMA(GCC diagnostic ignored "-Wunused-but-set-variable")
85 #elif defined(_MSC_VER)
86 # define SYS_PRAGMA_DISABLE_UNUSED_BUT_SET_VARIABLE() \
87  SYS_PRAGMA(warning(disable: 4189))
88 #else
89 # define SYS_PRAGMA_DISABLE_UNUSED_BUT_SET_VARIABLE()
90 #endif
91 #if SYS_IS_GCC_GE(4, 6) || defined(__clang__)
92 # define SYS_PRAGMA_DISABLE_COMMENT_WARNING() \
93  SYS_PRAGMA(GCC diagnostic ignored "-Wcomment")
94 #else
95 # define SYS_PRAGMA_DISABLE_COMMENT_WARNING()
96 #endif
97 #if SYS_IS_GCC_GE(4, 6) || defined(__clang__)
98 # define SYS_PRAGMA_DISABLE_MISSING_FIELD_INITIALIZERS() \
99  SYS_PRAGMA(GCC diagnostic ignored "-Wmissing-field-initializers")
100 #else
101 # define SYS_PRAGMA_DISABLE_MISSING_FIELD_INITIALIZERS()
102 #endif
103 #if SYS_IS_GCC_GE(4, 6) || defined(__clang__)
104 # define SYS_PRAGMA_DISABLE_NON_VIRTUAL_DTOR() \
105  SYS_PRAGMA(GCC diagnostic ignored "-Wnon-virtual-dtor")
106 #else
107 # define SYS_PRAGMA_DISABLE_NON_VIRTUAL_DTOR() \
108  SYS_PRAGMA(warning(disable: 4265))
109 #endif
110 #if SYS_IS_GCC_GE(4, 6) && !defined(__clang__)
111 # define SYS_PRAGMA_DISABLE_FREE_NONHEAP_OBJECT() \
112  SYS_PRAGMA(GCC diagnostic ignored "-Wfree-nonheap-object")
113 #else
114 # define SYS_PRAGMA_DISABLE_FREE_NONHEAP_OBJECT()
115 #endif
116 
117 #if SYS_IS_GCC_GE(4, 8) && !defined(__clang__)
118 # define SYS_PRAGMA_DISABLE_INVALID_OFFSETOF() \
119  SYS_PRAGMA(GCC diagnostic ignored "-Winvalid-offsetof")
120 #else
121 # define SYS_PRAGMA_DISABLE_INVALID_OFFSETOF()
122 #endif
123 
124 #if defined(__clang__)
125 # define SYS_PRAGMA_DISABLE_INCONSISTENT_OVERRIDE() \
126  SYS_PRAGMA(GCC diagnostic ignored "-Winconsistent-missing-override")
127 #else
128 # define SYS_PRAGMA_DISABLE_INCONSISTENT_OVERRIDE()
129 #endif
130 
131 #if SYS_IS_GCC_GE(4, 8) && !defined(__clang__)
132 # define SYS_PRAGMA_DISABLE_MAYBE_UNINITIALIZED() \
133  SYS_PRAGMA(GCC diagnostic ignored "-Wmaybe-uninitialized")
134 #else
135 # define SYS_PRAGMA_DISABLE_MAYBE_UNINITIALIZED()
136 #endif
137 
138 #if defined(__clang__)
139 # define SYS_PRAGMA_DISABLE_VARARGS() \
140  SYS_PRAGMA(GCC diagnostic ignored "-Wvarargs")
141 #else
142 # define SYS_PRAGMA_DISABLE_VARARGS()
143 #endif
144 
145 // This can be used to disable the warning about ignored attributes on
146 // templates. We're likely hitting:
147 // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=50044
148 #if SYS_IS_GCC_GE(4, 8) && !defined(__clang__)
149 # define SYS_PRAGMA_DISABLE_ATTRIBUTES() \
150  SYS_PRAGMA(GCC diagnostic ignored "-Wattributes")
151 #else
152 # define SYS_PRAGMA_DISABLE_ATTRIBUTES()
153 #endif
154 
155 #if defined(__GNUC__)
156 # define SYS_UNUSED_VAR_ATTRIB __attribute__((unused))
157 #else
158 # define SYS_UNUSED_VAR_ATTRIB
159 #endif
160 
161 #endif // __SYS_PRAGMA_H_INCLUDED__