|
363 | 363 | #define GTEST_DISABLE_MSC_WARNINGS_POP_() |
364 | 364 | #endif |
365 | 365 |
|
366 | | -// Clang on Windows does not understand MSVC's pragma warning. |
367 | | -// We need clang-specific way to disable function deprecation warning. |
368 | | -#ifdef __clang__ |
369 | | -#define GTEST_DISABLE_MSC_DEPRECATED_PUSH_() \ |
| 366 | +// Pragmas to disable function deprecation warnings. |
| 367 | +#if defined(__clang__) |
| 368 | +#define GTEST_DISABLE_DEPRECATED_PUSH_() \ |
370 | 369 | _Pragma("clang diagnostic push") \ |
371 | 370 | _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") \ |
372 | 371 | _Pragma("clang diagnostic ignored \"-Wdeprecated-implementations\"") |
373 | | -#define GTEST_DISABLE_MSC_DEPRECATED_POP_() _Pragma("clang diagnostic pop") |
| 372 | +#define GTEST_DISABLE_DEPRECATED_POP_() _Pragma("clang diagnostic pop") |
| 373 | +#elif defined(__GNUC__) |
| 374 | +#define GTEST_DISABLE_DEPRECATED_PUSH_() \ |
| 375 | + _Pragma("GCC diagnostic push") \ |
| 376 | + _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") |
| 377 | +#define GTEST_DISABLE_DEPRECATED_POP_() _Pragma("GCC diagnostic pop") |
| 378 | +#elif defined(_MSC_VER) |
| 379 | +#define GTEST_DISABLE_DEPRECATED_PUSH_() GTEST_DISABLE_MSC_WARNINGS_PUSH_(4996) |
| 380 | +#define GTEST_DISABLE_DEPRECATED_POP_() GTEST_DISABLE_MSC_WARNINGS_POP_() |
374 | 381 | #else |
375 | | -#define GTEST_DISABLE_MSC_DEPRECATED_PUSH_() \ |
376 | | - GTEST_DISABLE_MSC_WARNINGS_PUSH_(4996) |
377 | | -#define GTEST_DISABLE_MSC_DEPRECATED_POP_() GTEST_DISABLE_MSC_WARNINGS_POP_() |
| 382 | +#define GTEST_DISABLE_DEPRECATED_PUSH_() |
| 383 | +#define GTEST_DISABLE_DEPRECATED_POP_() |
378 | 384 | #endif |
379 | 385 |
|
380 | 386 | // Brings in definitions for functions used in the testing::internal::posix |
@@ -2119,7 +2125,7 @@ inline int IsATTY(int fd) { |
2119 | 2125 |
|
2120 | 2126 | // Functions deprecated by MSVC 8.0. |
2121 | 2127 |
|
2122 | | -GTEST_DISABLE_MSC_DEPRECATED_PUSH_() |
| 2128 | +GTEST_DISABLE_DEPRECATED_PUSH_() |
2123 | 2129 |
|
2124 | 2130 | // ChDir(), FReopen(), FDOpen(), Read(), Write(), Close(), and |
2125 | 2131 | // StrError() aren't needed on Windows CE at this time and thus not |
@@ -2181,7 +2187,7 @@ inline const char* GetEnv(const char* name) { |
2181 | 2187 | #endif |
2182 | 2188 | } |
2183 | 2189 |
|
2184 | | -GTEST_DISABLE_MSC_DEPRECATED_POP_() |
| 2190 | +GTEST_DISABLE_DEPRECATED_POP_() |
2185 | 2191 |
|
2186 | 2192 | #ifdef GTEST_OS_WINDOWS_MOBILE |
2187 | 2193 | // Windows CE has no C library. The abort() function is used in |
@@ -2302,22 +2308,29 @@ using TimeInMillis = int64_t; // Represents time in milliseconds. |
2302 | 2308 |
|
2303 | 2309 | // Macros for defining flags. |
2304 | 2310 | #define GTEST_DEFINE_bool_(name, default_val, doc) \ |
| 2311 | + GTEST_DECLARE_bool_(name); \ |
2305 | 2312 | namespace testing { \ |
2306 | 2313 | GTEST_API_ bool GTEST_FLAG(name) = (default_val); \ |
2307 | 2314 | } \ |
2308 | 2315 | static_assert(true, "no-op to require trailing semicolon") |
2309 | 2316 | #define GTEST_DEFINE_int32_(name, default_val, doc) \ |
| 2317 | + GTEST_DECLARE_int32_(name); \ |
2310 | 2318 | namespace testing { \ |
2311 | 2319 | GTEST_API_ std::int32_t GTEST_FLAG(name) = (default_val); \ |
2312 | 2320 | } \ |
2313 | 2321 | static_assert(true, "no-op to require trailing semicolon") |
2314 | 2322 | #define GTEST_DEFINE_string_(name, default_val, doc) \ |
| 2323 | + GTEST_DECLARE_string_(name); \ |
2315 | 2324 | namespace testing { \ |
2316 | 2325 | GTEST_API_ ::std::string GTEST_FLAG(name) = (default_val); \ |
2317 | 2326 | } \ |
2318 | 2327 | static_assert(true, "no-op to require trailing semicolon") |
2319 | 2328 |
|
2320 | 2329 | // Macros for declaring flags. |
| 2330 | +// |
| 2331 | +// We also need to declare the flag in the public namespace to avoid triggering |
| 2332 | +// -Wmissing-variable-declarations warnings, as reported here: |
| 2333 | +// https://github.com/google/googletest/issues/4897 |
2321 | 2334 | #define GTEST_DECLARE_bool_(name) \ |
2322 | 2335 | namespace testing { \ |
2323 | 2336 | GTEST_API_ extern bool GTEST_FLAG(name); \ |
|
0 commit comments