From f3cf7a452c54e095d6efa3d1cf752e0c54c747e2 Mon Sep 17 00:00:00 2001 From: Johannes Kauffmann <19662702+JohannesKauffmann@users.noreply.github.com> Date: Mon, 29 Aug 2022 23:17:53 +0000 Subject: [PATCH] Fix -Wundef warnings for MINGW_HAS_SECURE_API Since 12e27e17deb3102f1f6f08ec19caf5e32becb3f8, it was assumed that the MINGW_HAS_SECURE_API macro was unconditionally defined. This is not always the case, and GCC produces -Wundef warnings when that happens. Fix this, by first checking if MINGW_HAS_SECURE_API is defined, and if so, also check that it does not evaluate to zero. As a drive-by, place parentheses around _MSC_VER for consistency. --- glslang/Include/Common.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/glslang/Include/Common.h b/glslang/Include/Common.h index 9042a1aa..a5b41cb3 100644 --- a/glslang/Include/Common.h +++ b/glslang/Include/Common.h @@ -66,7 +66,7 @@ std::string to_string(const T& val) { } #endif -#if (defined(_MSC_VER) && _MSC_VER < 1900 /*vs2015*/) || MINGW_HAS_SECURE_API +#if (defined(_MSC_VER) && _MSC_VER < 1900 /*vs2015*/) || (defined(MINGW_HAS_SECURE_API) && MINGW_HAS_SECURE_API) #include #ifndef snprintf #define snprintf sprintf_s @@ -218,7 +218,7 @@ template T Max(const T a, const T b) { return a > b ? a : b; } // // Create a TString object from an integer. // -#if defined _MSC_VER || MINGW_HAS_SECURE_API +#if defined(_MSC_VER) || (defined(MINGW_HAS_SECURE_API) && MINGW_HAS_SECURE_API) inline const TString String(const int i, const int base = 10) { char text[16]; // 32 bit ints are at most 10 digits in base 10