Medial Code Documentation
Loading...
Searching...
No Matches
DisableStupidWarnings.h
1#ifndef EIGEN_WARNINGS_DISABLED
2#define EIGEN_WARNINGS_DISABLED
3
4#if defined(_MSC_VER)
5 // 4100 - unreferenced formal parameter (occurred e.g. in aligned_allocator::destroy(pointer p))
6 // 4101 - unreferenced local variable
7 // 4127 - conditional expression is constant
8 // 4181 - qualifier applied to reference type ignored
9 // 4211 - nonstandard extension used : redefined extern to static
10 // 4244 - 'argument' : conversion from 'type1' to 'type2', possible loss of data
11 // 4273 - QtAlignedMalloc, inconsistent DLL linkage
12 // 4324 - structure was padded due to declspec(align())
13 // 4503 - decorated name length exceeded, name was truncated
14 // 4512 - assignment operator could not be generated
15 // 4522 - 'class' : multiple assignment operators specified
16 // 4700 - uninitialized local variable 'xyz' used
17 // 4714 - function marked as __forceinline not inlined
18 // 4717 - 'function' : recursive on all control paths, function will cause runtime stack overflow
19 // 4800 - 'type' : forcing value to bool 'true' or 'false' (performance warning)
20 #ifndef EIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS
21 #pragma warning( push )
22 #endif
23 #pragma warning( disable : 4100 4101 4127 4181 4211 4244 4273 4324 4503 4512 4522 4700 4714 4717 4800)
24
25#elif defined __INTEL_COMPILER
26 // 2196 - routine is both "inline" and "noinline" ("noinline" assumed)
27 // ICC 12 generates this warning even without any inline keyword, when defining class methods 'inline' i.e. inside of class body
28 // typedef that may be a reference type.
29 // 279 - controlling expression is constant
30 // ICC 12 generates this warning on assert(constant_expression_depending_on_template_params) and frankly this is a legitimate use case.
31 // 1684 - conversion from pointer to same-sized integral type (potential portability problem)
32 // 2259 - non-pointer conversion from "Eigen::Index={ptrdiff_t={long}}" to "int" may lose significant bits
33 #ifndef EIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS
34 #pragma warning push
35 #endif
36 #pragma warning disable 2196 279 1684 2259
37
38#elif defined __clang__
39 #ifndef EIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS
40 #pragma clang diagnostic push
41 #endif
42 #if defined(__has_warning)
43 // -Wconstant-logical-operand - warning: use of logical && with constant operand; switch to bitwise & or remove constant
44 // this is really a stupid warning as it warns on compile-time expressions involving enums
45 #if __has_warning("-Wconstant-logical-operand")
46 #pragma clang diagnostic ignored "-Wconstant-logical-operand"
47 #endif
48 #if __has_warning("-Wimplicit-int-float-conversion")
49 #pragma clang diagnostic ignored "-Wimplicit-int-float-conversion"
50 #endif
51 #if ( defined(__ALTIVEC__) || defined(__VSX__) ) && __cplusplus < 201103L
52 // warning: generic selections are a C11-specific feature
53 // ignoring warnings thrown at vec_ctf in Altivec/PacketMath.h
54 #if __has_warning("-Wc11-extensions")
55 #pragma clang diagnostic ignored "-Wc11-extensions"
56 #endif
57 #endif
58 #endif
59
60#elif defined __GNUC__ && !defined(__FUJITSU)
61
62 #if (!defined(EIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS)) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
63 #pragma GCC diagnostic push
64 #endif
65 // g++ warns about local variables shadowing member functions, which is too strict
66 #pragma GCC diagnostic ignored "-Wshadow"
67 #if __GNUC__ == 4 && __GNUC_MINOR__ < 8
68 // Until g++-4.7 there are warnings when comparing unsigned int vs 0, even in templated functions:
69 #pragma GCC diagnostic ignored "-Wtype-limits"
70 #endif
71 #if __GNUC__>=6
72 #pragma GCC diagnostic ignored "-Wignored-attributes"
73 #endif
74 #if __GNUC__==7
75 // See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89325
76 #pragma GCC diagnostic ignored "-Wattributes"
77 #endif
78#endif
79
80#if defined __NVCC__
81 // MSVC 14.16 (required by CUDA 9.*) does not support the _Pragma keyword, so
82 // we instead use Microsoft's __pragma extension.
83 #if defined _MSC_VER
84 #define EIGEN_MAKE_PRAGMA(X) __pragma(#X)
85 #else
86 #define EIGEN_MAKE_PRAGMA(X) _Pragma(#X)
87 #endif
88 #if defined __NVCC_DIAG_PRAGMA_SUPPORT__
89 #define EIGEN_NV_DIAG_SUPPRESS(X) EIGEN_MAKE_PRAGMA(nv_diag_suppress X)
90 #else
91 #define EIGEN_NV_DIAG_SUPPRESS(X) EIGEN_MAKE_PRAGMA(diag_suppress X)
92 #endif
93
94 EIGEN_NV_DIAG_SUPPRESS(boolean_controlling_expr_is_constant)
95 // Disable the "statement is unreachable" message
96 EIGEN_NV_DIAG_SUPPRESS(code_is_unreachable)
97 // Disable the "dynamic initialization in unreachable code" message
98 EIGEN_NV_DIAG_SUPPRESS(initialization_not_reachable)
99 // Disable the "invalid error number" message that we get with older versions of nvcc
100 EIGEN_NV_DIAG_SUPPRESS(1222)
101 // Disable the "calling a __host__ function from a __host__ __device__ function is not allowed" messages (yes, there are many of them and they seem to change with every version of the compiler)
102 EIGEN_NV_DIAG_SUPPRESS(2527)
103 EIGEN_NV_DIAG_SUPPRESS(2529)
104 EIGEN_NV_DIAG_SUPPRESS(2651)
105 EIGEN_NV_DIAG_SUPPRESS(2653)
106 EIGEN_NV_DIAG_SUPPRESS(2668)
107 EIGEN_NV_DIAG_SUPPRESS(2669)
108 EIGEN_NV_DIAG_SUPPRESS(2670)
109 EIGEN_NV_DIAG_SUPPRESS(2671)
110 EIGEN_NV_DIAG_SUPPRESS(2735)
111 EIGEN_NV_DIAG_SUPPRESS(2737)
112 EIGEN_NV_DIAG_SUPPRESS(2739)
113 EIGEN_NV_DIAG_SUPPRESS(2885)
114 EIGEN_NV_DIAG_SUPPRESS(2888)
115 EIGEN_NV_DIAG_SUPPRESS(2976)
116 EIGEN_NV_DIAG_SUPPRESS(2979)
117 EIGEN_NV_DIAG_SUPPRESS(20011)
118 EIGEN_NV_DIAG_SUPPRESS(20014)
119 // Disable the "// __device__ annotation is ignored on a function(...) that is
120 // explicitly defaulted on its first declaration" message.
121 // The __device__ annotation seems to actually be needed in some cases,
122 // otherwise resulting in kernel runtime errors.
123 EIGEN_NV_DIAG_SUPPRESS(2886)
124 EIGEN_NV_DIAG_SUPPRESS(2977)
125 EIGEN_NV_DIAG_SUPPRESS(20012)
126 #undef EIGEN_NV_DIAG_SUPPRESS
127 #undef EIGEN_MAKE_PRAGMA
128#endif
129
130#else
131// warnings already disabled:
132# ifndef EIGEN_WARNINGS_DISABLED_2
133# define EIGEN_WARNINGS_DISABLED_2
134# elif defined(EIGEN_INTERNAL_DEBUGGING)
135# error "Do not include \"DisableStupidWarnings.h\" recursively more than twice!"
136# endif
137
138#endif // not EIGEN_WARNINGS_DISABLED