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