From: nhmall Date: Wed, 7 Jul 2021 13:05:22 +0000 (-0400) Subject: do vs2017 warnings.h a little differently than vs2019 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=216c26aaef9c0e495818783a37c62c7d46d3ec07;p=nethack do vs2017 warnings.h a little differently than vs2019 fixes #545 --- diff --git a/include/warnings.h b/include/warnings.h index a97a22c0c..28da4d108 100644 --- a/include/warnings.h +++ b/include/warnings.h @@ -68,6 +68,7 @@ #define STDC_Pragma_AVAILABLE #elif defined(_MSC_VER) +#if _MSC_VER > 1916 #define DISABLE_WARNING_UNREACHABLE_CODE \ _Pragma("warning( push )") \ _Pragma("warning( disable : 4702 )") @@ -81,6 +82,21 @@ #define RESTORE_WARNING_FORMAT_NONLITERAL _Pragma("warning( pop )") #define RESTORE_WARNINGS _Pragma("warning( pop )") #define STDC_Pragma_AVAILABLE +#else /* Visual Studio prior to 2019 below */ +#define DISABLE_WARNING_UNREACHABLE_CODE \ + __pragma(warning(push)) \ + __pragma(warning(disable:4702)) +#define DISABLE_WARNING_FORMAT_NONLITERAL \ + __pragma(warning(push)) \ + __pragma(warning(disable:4774)) +#define DISABLE_WARNING_CONDEXPR_IS_CONSTANT \ + __pragma(warning(push)) \ + __pragma(warning(disable:4127)) +#define RESTORE_WARNING_CONDEXPR_IS_CONSTANT __pragma(warning(pop)) +#define RESTORE_WARNING_FORMAT_NONLITERAL __pragma(warning(pop)) +#define RESTORE_WARNINGS __pragma(warning(pop)) +#define STDC_Pragma_AVAILABLE +#endif /* vs2019 or vs2017 */ #endif /* various compiler detections */ #endif /* ACTIVATE_WARNING_PRAGMAS */ diff --git a/sys/windows/consoletty.c b/sys/windows/consoletty.c index c27409e6e..5471e501f 100644 --- a/sys/windows/consoletty.c +++ b/sys/windows/consoletty.c @@ -1899,11 +1899,10 @@ void nethack_enter_consoletty() /* grow the size of the console buffer if it is not wide enough */ if (console.origcsbi.dwSize.X < console.width) { - COORD screen_size = { - screen_size.Y = console.origcsbi.dwSize.Y, - screen_size.X = console.width - }; + COORD screen_size = {0}; + screen_size.Y = console.origcsbi.dwSize.Y, + screen_size.X = console.width; SetConsoleScreenBufferSize(console.hConOut, screen_size); } diff --git a/win/win32/mhmap.c b/win/win32/mhmap.c index 0af2b05dc..85ba2da0a 100644 --- a/win/win32/mhmap.c +++ b/win/win32/mhmap.c @@ -965,8 +965,11 @@ paintGlyph(PNHMapWindow data, int i, int j, RECT * rect) DeleteObject(brush); intensity = (wch == 0x2591 ? 100 : 200); brush = CreateSolidBrush(RGB(intensity, intensity, intensity)); - RECT smallRect = { rect->left + 1, rect->top + 1, - rect->right - 1, rect->bottom - 1 }; + RECT smallRect = {0}; + smallRect.left = rect->left + 1; + smallRect.top = rect->top + 1; + smallRect.right = rect->right - 1; + smallRect.bottom = rect->bottom - 1; FillRect(data->backBufferDC, &smallRect, brush); DeleteObject(brush); } else {