DNDSR
0.1.0.dev1+gcd065ad
Distributed Numeric Data Structure for CFV
Loading...
Searching...
No Matches
Warnings.hpp
Go to the documentation of this file.
1
#pragma once
2
/// @file Warnings.hpp
3
/// @brief Cross-compiler macros for saving / restoring / disabling warnings.
4
///
5
/// Typical pattern around third-party headers that generate noise:
6
/// ```cpp
7
/// DISABLE_WARNING_PUSH
8
/// DISABLE_WARNING_UNUSED_VALUE
9
/// #include "noisy_header.h"
10
/// DISABLE_WARNING_POP
11
/// ```
12
///
13
/// Each supported compiler (MSVC, clang-MSVC, clang, GCC) provides the full
14
/// macro set; others fall through to no-ops.
15
16
/*------------------------------------------*/
17
// Warning disabler:
18
19
#if defined(_MSC_VER) && defined(_WIN32) && !defined(__clang__)
20
#define DISABLE_WARNING_PUSH __pragma(warning(push))
21
#define DISABLE_WARNING_POP __pragma(warning(pop))
22
#define DISABLE_WARNING(warningNumber) __pragma(warning(disable : warningNumber))
23
24
#define DISABLE_WARNING_UNREFERENCED_FORMAL_PARAMETER DISABLE_WARNING(4100)
25
#define DISABLE_WARNING_UNREFERENCED_FUNCTION DISABLE_WARNING(4505)
26
#define DISABLE_WARNING_DEPRECATED_DECLARATIONS
27
#define DISABLE_WARNING_UNUSED_VALUE
28
#define DISABLE_WARNING_MAYBE_UNINITIALIZED
29
#define DISABLE_WARNING_CLASS_MEMACCESS
30
// other warnings you want to deactivate...
31
32
#elif defined(_MSC_VER) && defined(_WIN32) && defined(__clang__)
// for clang-msvc on win, change a bit from unix version
33
34
#define DO_PRAGMA(X) _Pragma(#X)
35
#define DISABLE_WARNING_PUSH DO_PRAGMA(GCC diagnostic push)
36
#define DISABLE_WARNING_POP DO_PRAGMA(GCC diagnostic pop)
37
#define DISABLE_WARNING(warningName) DO_PRAGMA(GCC diagnostic ignored warningName)
38
39
#define DISABLE_WARNING_UNREFERENCED_FORMAL_PARAMETER DISABLE_WARNING("-Wunused-parameter")
40
#define DISABLE_WARNING_UNREFERENCED_FUNCTION DISABLE_WARNING("-Wunused-function")
41
#define DISABLE_WARNING_DEPRECATED_DECLARATIONS DISABLE_WARNING("-Wdeprecated-declarations")
42
#define DISABLE_WARNING_UNUSED_VALUE DISABLE_WARNING("-Wunused-value")
43
#define DISABLE_WARNING_MAYBE_UNINITIALIZED
44
#define DISABLE_WARNING_CLASS_MEMACCESS
45
46
#elif defined(__clang__)
// unix + gcc/clang
47
48
#define DO_PRAGMA(X) _Pragma(#X)
49
#define DISABLE_WARNING_PUSH DO_PRAGMA(GCC diagnostic push)
50
#define DISABLE_WARNING_POP DO_PRAGMA(GCC diagnostic pop)
51
#define DISABLE_WARNING(warningName) DO_PRAGMA(GCC diagnostic ignored warningName)
52
53
#define DISABLE_WARNING_UNREFERENCED_FORMAL_PARAMETER DISABLE_WARNING("-Wunused-parameter")
54
#define DISABLE_WARNING_UNREFERENCED_FUNCTION DISABLE_WARNING("-Wunused-function")
55
#define DISABLE_WARNING_DEPRECATED_DECLARATIONS DISABLE_WARNING("-Wdeprecated-declarations")
56
#define DISABLE_WARNING_UNUSED_VALUE DISABLE_WARNING("-Wunused-value")
57
#define DISABLE_WARNING_MAYBE_UNINITIALIZED
// not supported by clang
58
#define DISABLE_WARNING_CLASS_MEMACCESS DISABLE_WARNING("-Wclass-memaccess")
59
60
#elif defined(__GNUC__)
// unix + gcc/clang
61
#define DO_PRAGMA(X) _Pragma(#X)
62
#define DISABLE_WARNING_PUSH DO_PRAGMA(GCC diagnostic push)
63
#define DISABLE_WARNING_POP DO_PRAGMA(GCC diagnostic pop)
64
#define DISABLE_WARNING(warningName) DO_PRAGMA(GCC diagnostic ignored warningName)
65
66
#define DISABLE_WARNING_UNREFERENCED_FORMAL_PARAMETER DISABLE_WARNING("-Wunused-parameter")
67
#define DISABLE_WARNING_UNREFERENCED_FUNCTION DISABLE_WARNING("-Wunused-function")
68
#define DISABLE_WARNING_DEPRECATED_DECLARATIONS DISABLE_WARNING("-Wdeprecated-declarations")
69
#define DISABLE_WARNING_UNUSED_VALUE DISABLE_WARNING("-Wunused-value")
70
#define DISABLE_WARNING_MAYBE_UNINITIALIZED DISABLE_WARNING("-Wmaybe-uninitialized")
71
#define DISABLE_WARNING_CLASS_MEMACCESS DISABLE_WARNING("-Wclass-memaccess")
72
#else
73
#define DISABLE_WARNING_PUSH
74
#define DISABLE_WARNING_POP
75
#define DISABLE_WARNING_UNREFERENCED_FORMAL_PARAMETER
76
#define DISABLE_WARNING_UNUSED_VALUE
77
#define DISABLE_WARNING_UNREFERENCED_FUNCTION
78
#define DISABLE_WARNING_CLASS_MEMACCESS
79
// other warnings you want to deactivate...
80
81
#endif
82
83
/*------------------------------------------*/
src
DNDS
Warnings.hpp
Generated by
1.9.8