jaulib v1.3.8
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_PMF_CONVERSIONS
48 #define PRAGMA_DISABLE_WARNING_STRINGOP_OVERFLOW
49 #define PRAGMA_DISABLE_WARNING_INT_OVERFLOW
50 #define PRAGMA_DISABLE_WARNING_RESTRICT
51 #define PRAGMA_DISABLE_WARNING_PEDANTIC
52 #define PRAGMA_DISABLE_WARNING_ZERO_LENGTH_ARRAY
53
54#elif defined(__GNUC__) || defined(__clang__)
55 #define DO_PRAGMA(X) _Pragma(#X)
56 #define PRAGMA_DISABLE_WARNING_PUSH DO_PRAGMA(GCC diagnostic push)
57 #define PRAGMA_DISABLE_WARNING_POP DO_PRAGMA(GCC diagnostic pop)
58 #define PRAGMA_DISABLE_WARNING(warningName) DO_PRAGMA(GCC diagnostic ignored #warningName)
59 #define PRAGMA_WARNING_ONLY(warningName) DO_PRAGMA(GCC diagnostic warning #warningName)
60
61 #define PRAGMA_DISABLE_WARNING_UNREFERENCED_FORMAL_PARAMETER PRAGMA_DISABLE_WARNING(-Wunused-parameter)
62 #define PRAGMA_DISABLE_WARNING_UNREFERENCED_FUNCTION PRAGMA_DISABLE_WARNING(-Wunused-function)
63 #define PRAGMA_DISABLE_WARNING_CPP PRAGMA_DISABLE_WARNING(-Wcpp)
64 #define PRAGMA_DISABLE_WARNING_MULTICHAR PRAGMA_DISABLE_WARNING(-Wmultichar)
65 #define PRAGMA_DISABLE_WARNING_NULL_DEREFERENCE PRAGMA_DISABLE_WARNING(-Wnull-dereference)
66 #define PRAGMA_DISABLE_WARNING_FORMAT_OVERFLOW PRAGMA_DISABLE_WARNING(-Wformat-overflow)
67 #define PRAGMA_DISABLE_WARNING_FORMAT_NONLITERAL PRAGMA_DISABLE_WARNING(-Wformat-nonliteral)
68 #if defined(__GNUC__) && !defined(__clang__)
69 #define PRAGMA_DISABLE_WARNING_PMF_CONVERSIONS PRAGMA_DISABLE_WARNING(-Wpmf-conversions)
70 #define PRAGMA_DISABLE_WARNING_STRINGOP_OVERFLOW PRAGMA_DISABLE_WARNING(-Wstringop-overflow)
71 #define PRAGMA_DISABLE_WARNING_INT_OVERFLOW
72 #define PRAGMA_DISABLE_WARNING_RESTRICT PRAGMA_DISABLE_WARNING(-Wrestrict)
73 #define PRAGMA_DISABLE_WARNING_PEDANTIC PRAGMA_DISABLE_WARNING(-Wpedantic)
74 #define PRAGMA_DISABLE_WARNING_ZERO_LENGTH_ARRAY
75 #else
76 #define PRAGMA_DISABLE_WARNING_PMF_CONVERSIONS
77 #define PRAGMA_DISABLE_WARNING_STRINGOP_OVERFLOW
78 #define PRAGMA_DISABLE_WARNING_INT_OVERFLOW PRAGMA_DISABLE_WARNING(-Winteger-overflow)
79 #define PRAGMA_DISABLE_WARNING_RESTRICT
80 #define PRAGMA_DISABLE_WARNING_PEDANTIC PRAGMA_DISABLE_WARNING(-Wpedantic)
81 #define PRAGMA_DISABLE_WARNING_ZERO_LENGTH_ARRAY PRAGMA_DISABLE_WARNING(-Wzero-length-array)
82 #endif
83
84#else
85 #define PRAGMA_DISABLE_WARNING_PUSH
86 #define PRAGMA_DISABLE_WARNING_POP
87 #define PRAGMA_DISABLE_WARNING_UNREFERENCED_FORMAL_PARAMETER
88 #define PRAGMA_DISABLE_WARNING_UNREFERENCED_FUNCTION
89 #define PRAGMA_DISABLE_WARNING_CPP
90 #define PRAGMA_DISABLE_WARNING_MULTICHAR
91 #define PRAGMA_DISABLE_WARNING_NULL_DEREFERENCE
92 #define PRAGMA_DISABLE_WARNING_FORMAT_OVERFLOW
93 #define PRAGMA_DISABLE_WARNING_FORMAT_NONLITERAL
94 #define PRAGMA_DISABLE_WARNING_PMF_CONVERSIONS
95 #define PRAGMA_DISABLE_WARNING_STRINGOP_OVERFLOW
96 #define PRAGMA_DISABLE_WARNING_INT_OVERFLOW
97 #define PRAGMA_DISABLE_WARNING_RESTRICT
98 #define PRAGMA_DISABLE_WARNING_PEDANTIC
99 #define PRAGMA_DISABLE_WARNING_ZERO_LENGTH_ARRAY
100
101#endif
102
103 /**@}*/
104
105} // namespace jau
106
107#endif /* CPP_PRAGMA_HPP_ */
__pack(...): Produces MSVC, clang and gcc compatible lead-in and -out macros.
Definition backtrace.hpp:32