From a08c03c5f52802c50a541d7283be31a4c3177807 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Fri, 3 Mar 2023 15:56:41 -0800 Subject: Always specify definitions for internal macros These macros should only be used within googletest, so changing them will not affect external users. This allows compiling with -Wundef (#3267). PiperOrigin-RevId: 513943800 Change-Id: I697b1005c29b0d5af06f583f202d86db48b567b9 --- googletest/include/gtest/internal/gtest-port.h | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h index f2b0bbf..ba5e9bc 100644 --- a/googletest/include/gtest/internal/gtest-port.h +++ b/googletest/include/gtest/internal/gtest-port.h @@ -202,16 +202,17 @@ // is suppressed. // GTEST_INTERNAL_HAS_ANY - for enabling UniversalPrinter or // UniversalPrinter specializations. +// Always defined to 0 or 1. // GTEST_INTERNAL_HAS_OPTIONAL - for enabling UniversalPrinter // or // UniversalPrinter -// specializations. +// specializations. Always defined to 0 or 1. // GTEST_INTERNAL_HAS_STRING_VIEW - for enabling Matcher or // Matcher -// specializations. +// specializations. Always defined to 0 or 1. // GTEST_INTERNAL_HAS_VARIANT - for enabling UniversalPrinter or // UniversalPrinter -// specializations. +// specializations. Always defined to 0 or 1. // // Synchronization: // Mutex, MutexLock, ThreadLocal, GetThreadCount() @@ -2389,6 +2390,10 @@ using Any = ::std::any; #endif // __has_include #endif // GTEST_HAS_ABSL +#ifndef GTEST_INTERNAL_HAS_ANY +#define GTEST_INTERNAL_HAS_ANY 0 +#endif + #if GTEST_HAS_ABSL // Always use absl::optional for UniversalPrinter<> specializations if // googletest is built with absl support. @@ -2421,6 +2426,10 @@ inline ::std::nullopt_t Nullopt() { return ::std::nullopt; } #endif // __has_include #endif // GTEST_HAS_ABSL +#ifndef GTEST_INTERNAL_HAS_OPTIONAL +#define GTEST_INTERNAL_HAS_OPTIONAL 0 +#endif + #if GTEST_HAS_ABSL // Always use absl::string_view for Matcher<> specializations if googletest // is built with absl support. @@ -2449,6 +2458,10 @@ using StringView = ::std::string_view; #endif // __has_include #endif // GTEST_HAS_ABSL +#ifndef GTEST_INTERNAL_HAS_STRING_VIEW +#define GTEST_INTERNAL_HAS_STRING_VIEW 0 +#endif + #if GTEST_HAS_ABSL // Always use absl::variant for UniversalPrinter<> specializations if googletest // is built with absl support. @@ -2478,6 +2491,10 @@ using Variant = ::std::variant; #endif // __has_include #endif // GTEST_HAS_ABSL +#ifndef GTEST_INTERNAL_HAS_VARIANT +#define GTEST_INTERNAL_HAS_VARIANT 0 +#endif + #if defined(GTEST_INTERNAL_CPLUSPLUS_LANG) && \ GTEST_INTERNAL_CPLUSPLUS_LANG < 201703L #define GTEST_INTERNAL_NEED_REDUNDANT_CONSTEXPR_DECL 1 -- cgit v0.12