libquentier 0.8.0
The library for rich desktop clients of Evernote service
Loading...
Searching...
No Matches
SuppressWarnings.h
1/*
2 * Copyright 2020-2024 Dmitry Ivanov
3 *
4 * This file is part of libquentier
5 *
6 * libquentier is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation, version 3 of the License.
9 *
10 * libquentier is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with libquentier. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#pragma once
20
22// Common macros
24
25#define STRINGIFY(a) #a
26
27// Define empty macros doing nothing for supported compilers, they would be used
28// as fallback when any of these compilers are not actually used
29
30#define SAVE_WARNINGS
31
32#define CLANG_SUPPRESS_WARNING(warning)
33#define GCC_SUPPRESS_WARNING(warning)
34#define MSVC_SUPPRESS_WARNING(warning)
35
36#define RESTORE_WARNINGS
37
39// Clang implementation
41
42#if defined(__clang__)
43
44#undef CLANG_SUPPRESS_WARNING
45
46#define CLANG_SUPPRESS_WARNING(warning) \
47 _Pragma(STRINGIFY(clang diagnostic ignored #warning))
48
49#undef SAVE_WARNINGS
50
51#define SAVE_WARNINGS _Pragma("clang diagnostic push")
52
53#undef RESTORE_WARNINGS
54
55#define RESTORE_WARNINGS _Pragma("clang diagnostic pop")
56
57#endif // clang
58
60// GCC implementation
62
63// Clang can mimic gcc so need to ensure it's indeed gcc
64#if defined(__GNUC__) && !defined(__clang__)
65
66#undef GCC_SUPPRESS_WARNING
67
68#define GCC_SUPPRESS_WARNING(warning) \
69 _Pragma(STRINGIFY(GCC diagnostic ignored #warning))
70
71#undef SAVE_WARNINGS
72
73#define SAVE_WARNINGS _Pragma("GCC diagnostic push")
74
75#undef RESTORE_WARNINGS
76
77#define RESTORE_WARNINGS _Pragma("GCC diagnostic pop")
78
79#endif // GCC
80
82// MSVC implementation
84
85#if defined(_MSC_VER)
86
87#undef MSVC_SUPPRESS_WARNING
88
89#define MSVC_SUPPRESS_WARNING(number) __pragma(warning(disable : number))
90
91#undef SAVE_WARNINGS
92
93#define SAVE_WARNINGS __pragma(warning(push))
94
95#undef RESTORE_WARNINGS
96
97#define RESTORE_WARNINGS __pragma(warning(pop))
98
99#endif // MSVC