|
17 | 17 | #define BSONCXX_V1_DETAIL_MACROS_HPP
|
18 | 18 |
|
19 | 19 | // Convert the given macro argument to a string literal, after macro expansion.
|
20 |
| -#define BSONCXX_STRINGIFY(...) BSONCXX_STRINGIFY_IMPL(__VA_ARGS__) |
21 |
| -#define BSONCXX_STRINGIFY_IMPL(...) #__VA_ARGS__ |
| 20 | +#define BSONCXX_PRIVATE_STRINGIFY(...) BSONCXX_PRIVATE_STRINGIFY_IMPL(__VA_ARGS__) |
| 21 | +#define BSONCXX_PRIVATE_STRINGIFY_IMPL(...) #__VA_ARGS__ |
22 | 22 |
|
23 | 23 | // Token-paste two macro arguments, after macro expansion
|
24 |
| -#define BSONCXX_CONCAT(A, ...) BSONCXX_CONCAT_IMPL(A, __VA_ARGS__) |
25 |
| -#define BSONCXX_CONCAT_IMPL(A, ...) A##__VA_ARGS__ |
| 24 | +#define BSONCXX_PRIVATE_CONCAT(A, ...) BSONCXX_PRIVATE_CONCAT_IMPL(A, __VA_ARGS__) |
| 25 | +#define BSONCXX_PRIVATE_CONCAT_IMPL(A, ...) A##__VA_ARGS__ |
26 | 26 |
|
27 | 27 | // Expands to a _Pragma() preprocessor directive, after macro expansion
|
28 | 28 | //
|
|
31 | 31 | //
|
32 | 32 | // Example:
|
33 | 33 | //
|
34 |
| -// BSONCXX_PRAGMA(GCC diagnostic ignore "-Wconversion") |
| 34 | +// BSONCXX_PRIVATE_PRAGMA(GCC diagnostic ignore "-Wconversion") |
35 | 35 | //
|
36 | 36 | // will become:
|
37 | 37 | //
|
38 | 38 | // _Pragma("GCC diagnostic ignore \"-Wconversion\"")
|
39 | 39 | //
|
40 |
| -#define BSONCXX_PRAGMA(...) _bsoncxxPragma(__VA_ARGS__) |
| 40 | +#define BSONCXX_PRIVATE_PRAGMA(...) BSONCXX_PRIVATE_PRAGMA_IMPL(__VA_ARGS__) |
41 | 41 | #ifdef _MSC_VER
|
42 | 42 | // Old MSVC doesn't recognize C++11 _Pragma(), but it always recognized __pragma
|
43 |
| -#define _bsoncxxPragma(...) __pragma(__VA_ARGS__) |
| 43 | +#define BSONCXX_PRIVATE_PRAGMA_IMPL(...) __pragma(__VA_ARGS__) |
44 | 44 | #else
|
45 |
| -#define _bsoncxxPragma(...) _Pragma(BSONCXX_STRINGIFY(__VA_ARGS__)) |
| 45 | +#define BSONCXX_PRIVATE_PRAGMA_IMPL(...) _Pragma(BSONCXX_PRIVATE_STRINGIFY(__VA_ARGS__)) |
46 | 46 | #endif
|
47 | 47 |
|
48 | 48 | // Use in a declaration position to force the appearence of a semicolon
|
49 | 49 | // as the next token. Use this for statement-like or declaration-like macros to
|
50 | 50 | // enforce that their call sites are followed by a semicolon
|
51 |
| -#define BSONCXX_FORCE_SEMICOLON static_assert(true, "") |
| 51 | +#define BSONCXX_PRIVATE_FORCE_SEMICOLON static_assert(true, "") |
52 | 52 |
|
53 | 53 | // Add a trailing noexcept, decltype-return, and return-body to a
|
54 | 54 | // function definition. (Not compatible with lambda expressions.)
|
55 | 55 | //
|
56 | 56 | // Example:
|
57 | 57 | //
|
58 | 58 | // template <typename T>
|
59 |
| -// auto foo(T x, T y) BSONCXX_RETURNS(x + y); |
| 59 | +// auto foo(T x, T y) BSONCXX_PRIVATE_RETURNS(x + y); |
60 | 60 | //
|
61 | 61 | // Becomes:
|
62 | 62 | //
|
|
65 | 65 | // -> decltype(x + y)
|
66 | 66 | // { return x + y };
|
67 | 67 | //
|
68 |
| -#define BSONCXX_RETURNS(...) \ |
| 68 | +#define BSONCXX_PRIVATE_RETURNS(...) \ |
69 | 69 | noexcept(noexcept(__VA_ARGS__))->decltype(__VA_ARGS__) { \
|
70 | 70 | return __VA_ARGS__; \
|
71 | 71 | } \
|
72 |
| - BSONCXX_FORCE_SEMICOLON |
| 72 | + BSONCXX_PRIVATE_FORCE_SEMICOLON |
73 | 73 |
|
74 | 74 | // @macro mongocxx_cxx14_constexpr
|
75 | 75 | // Expands to `constexpr` if compiling as c++14 or greater, otherwise
|
|
78 | 78 | // Use this on functions that can only be constexpr in C++14 or newer, including
|
79 | 79 | // non-const member functions.
|
80 | 80 | #if __cplusplus >= 201402L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201402L && _MSC_VER > 1910)
|
81 |
| -#define bsoncxx_cxx14_constexpr constexpr |
| 81 | +#define BSONCXX_PRIVATE_CONSTEXPR_CXX14 constexpr |
82 | 82 | #else
|
83 |
| -#define bsoncxx_cxx14_constexpr inline |
| 83 | +#define BSONCXX_PRIVATE_CONSTEXPR_CXX14 inline |
84 | 84 | #endif
|
85 | 85 |
|
86 |
| -#define BSONCXX_IF_MSVC(...) |
87 |
| -#define BSONCXX_IF_GCC(...) |
88 |
| -#define BSONCXX_IF_CLANG(...) |
89 |
| -#define BSONCXX_IF_GNU_LIKE(...) \ |
90 |
| - BSONCXX_IF_GCC(__VA_ARGS__) \ |
91 |
| - BSONCXX_IF_CLANG(__VA_ARGS__) |
| 86 | +#define BSONCXX_PRIVATE_IF_MSVC(...) |
| 87 | +#define BSONCXX_PRIVATE_IF_GCC(...) |
| 88 | +#define BSONCXX_PRIVATE_IF_CLANG(...) |
| 89 | +#define BSONCXX_PRIVATE_IF_GNU_LIKE(...) \ |
| 90 | + BSONCXX_PRIVATE_IF_GCC(__VA_ARGS__) \ |
| 91 | + BSONCXX_PRIVATE_IF_CLANG(__VA_ARGS__) |
92 | 92 |
|
93 | 93 | // clang-format off
|
94 | 94 | #ifdef __GNUC__
|
95 | 95 | #ifdef __clang__
|
96 |
| - #undef BSONCXX_IF_CLANG |
97 |
| - #define BSONCXX_IF_CLANG(...) __VA_ARGS__ |
| 96 | + #undef BSONCXX_PRIVATE_IF_CLANG |
| 97 | + #define BSONCXX_PRIVATE_IF_CLANG(...) __VA_ARGS__ |
98 | 98 | #else
|
99 |
| - #undef BSONCXX_IF_GCC |
100 |
| - #define BSONCXX_IF_GCC(...) __VA_ARGS__ |
| 99 | + #undef BSONCXX_PRIVATE_IF_GCC |
| 100 | + #define BSONCXX_PRIVATE_IF_GCC(...) __VA_ARGS__ |
101 | 101 | #endif
|
102 | 102 | #elif defined(_MSC_VER)
|
103 |
| - #undef BSONCXX_IF_MSVC |
104 |
| - #define BSONCXX_IF_MSVC(...) __VA_ARGS__ |
| 103 | + #undef BSONCXX_PRIVATE_IF_MSVC |
| 104 | + #define BSONCXX_PRIVATE_IF_MSVC(...) __VA_ARGS__ |
105 | 105 | #endif
|
106 | 106 | // clang-format on
|
107 | 107 |
|
|
115 | 115 | // - MSVC(<id-integer-literal>)
|
116 | 116 | //
|
117 | 117 | // The "GNU" form applies to both GCC and Clang
|
118 |
| -#define BSONCXX_DISABLE_WARNING(Spec) \ |
119 |
| - BSONCXX_CONCAT(_bsoncxxDisableWarningImpl_for_, Spec) \ |
120 |
| - BSONCXX_FORCE_SEMICOLON |
| 118 | +#define BSONCXX_PRIVATE_WARNINGS_DISABLE(Spec) \ |
| 119 | + BSONCXX_PRIVATE_CONCAT(BSONCXX_PRIVATE_WARNINGS_DISABLE_IMPL_FOR_, Spec) \ |
| 120 | + BSONCXX_PRIVATE_FORCE_SEMICOLON |
121 | 121 |
|
122 | 122 | // Push the current compiler diagnostics settings state
|
123 |
| -#define BSONCXX_PUSH_WARNINGS() \ |
124 |
| - BSONCXX_IF_GNU_LIKE(BSONCXX_PRAGMA(GCC diagnostic push)) \ |
125 |
| - BSONCXX_IF_MSVC(BSONCXX_PRAGMA(warning(push))) \ |
126 |
| - BSONCXX_FORCE_SEMICOLON |
| 123 | +#define BSONCXX_PRIVATE_WARNINGS_PUSH() \ |
| 124 | + BSONCXX_PRIVATE_IF_GNU_LIKE(BSONCXX_PRIVATE_PRAGMA(GCC diagnostic push)) \ |
| 125 | + BSONCXX_PRIVATE_IF_MSVC(BSONCXX_PRIVATE_PRAGMA(warning(push))) \ |
| 126 | + BSONCXX_PRIVATE_FORCE_SEMICOLON |
127 | 127 |
|
128 | 128 | // Restore prior compiler diagnostics settings from before the most
|
129 |
| -// recent BSONCXX_PUSH_WARNINGS() |
130 |
| -#define BSONCXX_POP_WARNINGS() \ |
131 |
| - BSONCXX_IF_GNU_LIKE(BSONCXX_PRAGMA(GCC diagnostic pop)) \ |
132 |
| - BSONCXX_IF_MSVC(BSONCXX_PRAGMA(warning(pop))) \ |
133 |
| - BSONCXX_FORCE_SEMICOLON |
| 129 | +// recent BSONCXX_PRIVATE_WARNINGS_PUSH() |
| 130 | +#define BSONCXX_PRIVATE_WARNINGS_POP() \ |
| 131 | + BSONCXX_PRIVATE_IF_GNU_LIKE(BSONCXX_PRIVATE_PRAGMA(GCC diagnostic pop)) \ |
| 132 | + BSONCXX_PRIVATE_IF_MSVC(BSONCXX_PRIVATE_PRAGMA(warning(pop))) \ |
| 133 | + BSONCXX_PRIVATE_FORCE_SEMICOLON |
134 | 134 |
|
135 |
| -#define _bsoncxxDisableWarningImpl_for_GCC(...) BSONCXX_IF_GCC(BSONCXX_PRAGMA(GCC diagnostic ignored __VA_ARGS__)) |
| 135 | +#define BSONCXX_PRIVATE_WARNINGS_DISABLE_IMPL_FOR_GCC(...) \ |
| 136 | + BSONCXX_PRIVATE_IF_GCC(BSONCXX_PRIVATE_PRAGMA(GCC diagnostic ignored __VA_ARGS__)) |
136 | 137 |
|
137 |
| -#define _bsoncxxDisableWarningImpl_for_Clang(...) BSONCXX_IF_CLANG(BSONCXX_PRAGMA(GCC diagnostic ignored __VA_ARGS__)) |
| 138 | +#define BSONCXX_PRIVATE_WARNINGS_DISABLE_IMPL_FOR_Clang(...) \ |
| 139 | + BSONCXX_PRIVATE_IF_CLANG(BSONCXX_PRIVATE_PRAGMA(GCC diagnostic ignored __VA_ARGS__)) |
138 | 140 |
|
139 |
| -#define _bsoncxxDisableWarningImpl_for_GNU(...) \ |
140 |
| - _bsoncxxDisableWarningImpl_for_GCC(__VA_ARGS__) _bsoncxxDisableWarningImpl_for_Clang(__VA_ARGS__) |
| 141 | +#define BSONCXX_PRIVATE_WARNINGS_DISABLE_IMPL_FOR_GNU(...) \ |
| 142 | + BSONCXX_PRIVATE_WARNINGS_DISABLE_IMPL_FOR_GCC(__VA_ARGS__) \ |
| 143 | + BSONCXX_PRIVATE_WARNINGS_DISABLE_IMPL_FOR_Clang(__VA_ARGS__) |
141 | 144 |
|
142 |
| -#define _bsoncxxDisableWarningImpl_for_MSVC(...) BSONCXX_IF_MSVC(BSONCXX_PRAGMA(warning(disable : __VA_ARGS__))) |
| 145 | +#define BSONCXX_PRIVATE_WARNINGS_DISABLE_IMPL_FOR_MSVC(...) \ |
| 146 | + BSONCXX_PRIVATE_IF_MSVC(BSONCXX_PRIVATE_PRAGMA(warning(disable : __VA_ARGS__))) |
143 | 147 |
|
144 |
| -#define BSONCXX_FWD(...) static_cast<decltype(__VA_ARGS__)&&>(__VA_ARGS__) |
| 148 | +#define BSONCXX_PRIVATE_FWD(...) static_cast<decltype(__VA_ARGS__)&&>(__VA_ARGS__) |
145 | 149 |
|
146 |
| -#define BSONCXX_UNREACHABLE \ |
147 |
| - if (1) { \ |
148 |
| - std::abort(); \ |
149 |
| - } else \ |
| 150 | +#define BSONCXX_PRIVATE_UNREACHABLE \ |
| 151 | + if (1) { \ |
| 152 | + std::abort(); \ |
| 153 | + } else \ |
150 | 154 | ((void)0)
|
151 | 155 |
|
152 | 156 | #endif // BSONCXX_V1_DETAIL_MACROS_HPP
|
|
0 commit comments