1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*++
Copyright (c) 2006 Microsoft Corporation
Module Name:
manage_warnings.h
Abstract:
Macros to control compiler build warnings.
Author:
Dave Detlefs 2026-07-20.
Revision History:
--*/
#pragma once
// #define PRAGMA_MACRO(s) _Pragma(s)
// In some cases, we wish to be able to terminate macros with semicolons,
// even when the semi is (strictly speaking) illegal when following the
// expansion of the macro. (The macro invocations can look like function
// invocations to some IDE's, and the lack of a trailing semi can confuse them.)
// In those cases, we add this DUMMY_DECL to the macro; it "consumes" the trailing
// semi, making it legal.
// Standard preprocessor concatenation gymnastics
#define CONCAT_IMPL(x, y) x##y
#define CONCAT(x, y) CONCAT_IMPL(x, y)
#define DUMMY_DECL using CONCAT(__dummy_decl_, __COUNTER__) = int
#define DO_PRAGMA(x) _Pragma(#x)
#ifdef __clang__
#define START_DISABLE_WARNING(s) \
_Pragma("clang diagnostic push") \
DO_PRAGMA(clang diagnostic ignored #s)
// This version should be used in decl contexts.
#define END_DISABLE_WARNING \
_Pragma("clang diagnostic pop") \
DUMMY_DECL
// This version should be used in statement contexts.
#define END_DISABLE_WARNING_STMT \
_Pragma("clang diagnostic pop")
#define START_DISABLE_EXTRA_SEMI_WARNING START_DISABLE_WARNING(-Wextra-semi)
#define START_DISABLE_COVERED_SWITCH_DEFAULT START_DISABLE_WARNING(-Wcovered-switch-default)
#else
#define START_DISABLE_EXTRA_SEMI_WARNING
#define START_DISABLE_COVERED_SWITCH_DEFAULT
#define END_DISABLE_WARNING
#define END_DISABLE_WARNING_STMT
#endif