jaulib v1.4.1
Jau Support Library (C++, Java, ..)
Loading...
Searching...
No Matches
cpp_pragma.hpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 Gothel Software e.K.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining
5 * a copy of this software and associated documentation files (the
6 * "Software"), to deal in the Software without restriction, including
7 * without limitation the rights to use, copy, modify, merge, publish,
8 * distribute, sublicense, and/or sell copies of the Software, and to
9 * permit persons to whom the Software is furnished to do so, subject to
10 * the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be
13 * included in all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 *
23 */
24
25#ifndef CPP_PRAGMA_HPP_
26#define CPP_PRAGMA_HPP_
27
28namespace jau {
29
30 /** \addtogroup CppLang
31 *
32 * @{
33 */
34
35#if defined(_MSC_VER)
36 #define PRAGMA_DISABLE_WARNING_PUSH __pragma(warning( push ))
37 #define PRAGMA_DISABLE_WARNING_POP __pragma(warning( pop ))
38 #define PRAGMA_DISABLE_WARNING(warningNumber) __pragma(warning( disable : warningNumber ))
39
40 #define PRAGMA_DISABLE_WARNING_UNREFERENCED_FORMAL_PARAMETER PRAGMA_DISABLE_WARNING(4100)
41 #define PRAGMA_DISABLE_WARNING_UNREFERENCED_FUNCTION PRAGMA_DISABLE_WARNING(4505)
42 #define PRAGMA_DISABLE_WARNING_CPP
43 #define PRAGMA_DISABLE_WARNING_MULTICHAR
44 #define PRAGMA_DISABLE_WARNING_NULL_DEREFERENCE
45 #define PRAGMA_DISABLE_WARNING_FORMAT_OVERFLOW
46 #define PRAGMA_DISABLE_WARNING_FORMAT_NONLITERAL
47 #define PRAGMA_DISABLE_WARNING_FORMAT_SECURITY
48 #define PRAGMA_DISABLE_WARNING_PMF_CONVERSIONS
49 #define PRAGMA_DISABLE_WARNING_STRINGOP_OVERFLOW
50 #define PRAGMA_DISABLE_WARNING_INT_OVERFLOW
51 #define PRAGMA_DISABLE_WARNING_RESTRICT
52 #define PRAGMA_DISABLE_WARNING_PEDANTIC
53 #define PRAGMA_DISABLE_WARNING_ZERO_LENGTH_ARRAY
54 #define PRAGMA_DISABLE_WARNING_TYPE_RANGE_LIMIT
55
56#elif defined(__GNUC__) || defined(__clang__)
57 #define DO_PRAGMA(X) _Pragma(#X)
58 #define PRAGMA_DISABLE_WARNING_PUSH DO_PRAGMA(GCC diagnostic push)
59 #define PRAGMA_DISABLE_WARNING_POP DO_PRAGMA(GCC diagnostic pop)
60 #define PRAGMA_DISABLE_WARNING(warningName) DO_PRAGMA(GCC diagnostic ignored #warningName)
61 #define PRAGMA_WARNING_ONLY(warningName) DO_PRAGMA(GCC diagnostic warning #warningName)
62
63 #define PRAGMA_DISABLE_WARNING_UNREFERENCED_FORMAL_PARAMETER PRAGMA_DISABLE_WARNING(-Wunused-parameter)
64 #define PRAGMA_DISABLE_WARNING_UNREFERENCED_FUNCTION PRAGMA_DISABLE_WARNING(-Wunused-function)
65 #define PRAGMA_DISABLE_WARNING_CPP PRAGMA_DISABLE_WARNING(-Wcpp)
66 #define PRAGMA_DISABLE_WARNING_MULTICHAR PRAGMA_DISABLE_WARNING(-Wmultichar)
67 #define PRAGMA_DISABLE_WARNING_NULL_DEREFERENCE PRAGMA_DISABLE_WARNING(-Wnull-dereference)
68 #define PRAGMA_DISABLE_WARNING_FORMAT_OVERFLOW PRAGMA_DISABLE_WARNING(-Wformat-overflow)
69 #define PRAGMA_DISABLE_WARNING_FORMAT_NONLITERAL PRAGMA_DISABLE_WARNING(-Wformat-nonliteral)
70 #define PRAGMA_DISABLE_WARNING_FORMAT_SECURITY PRAGMA_DISABLE_WARNING(-Wformat-security)
71 #if defined(__GNUC__) && !defined(__clang__)
72 #define PRAGMA_DISABLE_WARNING_PMF_CONVERSIONS PRAGMA_DISABLE_WARNING(-Wpmf-conversions)
73 #define PRAGMA_DISABLE_WARNING_STRINGOP_OVERFLOW PRAGMA_DISABLE_WARNING(-Wstringop-overflow)
74 #define PRAGMA_DISABLE_WARNING_INT_OVERFLOW
75 #define PRAGMA_DISABLE_WARNING_RESTRICT PRAGMA_DISABLE_WARNING(-Wrestrict)
76 #define PRAGMA_DISABLE_WARNING_PEDANTIC PRAGMA_DISABLE_WARNING(-Wpedantic)
77 #define PRAGMA_DISABLE_WARNING_ZERO_LENGTH_ARRAY
78 #define PRAGMA_DISABLE_WARNING_TYPE_RANGE_LIMIT PRAGMA_DISABLE_WARNING(-Wtype-limits) PRAGMA_DISABLE_WARNING(-Wtautological-compare)
79 #else
80 #define PRAGMA_DISABLE_WARNING_PMF_CONVERSIONS
81 #define PRAGMA_DISABLE_WARNING_STRINGOP_OVERFLOW
82 #define PRAGMA_DISABLE_WARNING_INT_OVERFLOW PRAGMA_DISABLE_WARNING(-Winteger-overflow)
83 #define PRAGMA_DISABLE_WARNING_RESTRICT
84 #define PRAGMA_DISABLE_WARNING_PEDANTIC PRAGMA_DISABLE_WARNING(-Wpedantic)
85 #define PRAGMA_DISABLE_WARNING_ZERO_LENGTH_ARRAY PRAGMA_DISABLE_WARNING(-Wzero-length-array)
86 #define PRAGMA_DISABLE_WARNING_TYPE_RANGE_LIMIT PRAGMA_DISABLE_WARNING(-Wtype-limits) PRAGMA_DISABLE_WARNING(-Wtautological-compare) \
87 PRAGMA_DISABLE_WARNING(-Wtautological-type-limit-compare)
88 #endif
89
90#else
91 #define PRAGMA_DISABLE_WARNING_PUSH
92 #define PRAGMA_DISABLE_WARNING_POP
93 #define PRAGMA_DISABLE_WARNING_UNREFERENCED_FORMAL_PARAMETER
94 #define PRAGMA_DISABLE_WARNING_UNREFERENCED_FUNCTION
95 #define PRAGMA_DISABLE_WARNING_CPP
96 #define PRAGMA_DISABLE_WARNING_MULTICHAR
97 #define PRAGMA_DISABLE_WARNING_NULL_DEREFERENCE
98 #define PRAGMA_DISABLE_WARNING_FORMAT_OVERFLOW
99 #define PRAGMA_DISABLE_WARNING_FORMAT_NONLITERAL
100 #define PRAGMA_DISABLE_WARNING_FORMAT_SECURITY
101 #define PRAGMA_DISABLE_WARNING_PMF_CONVERSIONS
102 #define PRAGMA_DISABLE_WARNING_STRINGOP_OVERFLOW
103 #define PRAGMA_DISABLE_WARNING_INT_OVERFLOW
104 #define PRAGMA_DISABLE_WARNING_RESTRICT
105 #define PRAGMA_DISABLE_WARNING_PEDANTIC
106 #define PRAGMA_DISABLE_WARNING_ZERO_LENGTH_ARRAY
107 #define PRAGMA_DISABLE_WARNING_TYPE_RANGE_LIMIT
108
109#endif
110
111 /**@}*/
112
113} // namespace jau
114
115#endif /* CPP_PRAGMA_HPP_ */
__pack(...): Produces MSVC, clang and gcc compatible lead-in and -out macros.
Definition backtrace.hpp:32