build: fix unknown pragma warning with mingw (#22533)

This checks MSVC toolchain with _MSC_VER macro before adding
pragma warning directive. It is specific to MSVC and shows
compiler warning with mingw gcc as following:

main.c:187: warning: ignoring '#pragma warning ' [-Wunknown-pragmas]
  187 | # pragma warning(suppress : 4996)
This commit is contained in:
Biswapriyo Nath 2023-03-05 19:22:32 +05:30 committed by GitHub
parent ba38f35d3e
commit 0775858703
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -184,8 +184,12 @@ void early_init(mparm_T *paramp)
ovi.dwOSVersionInfoSize = sizeof(ovi);
// Disable warning about GetVersionExA being deprecated. There doesn't seem to be a convenient
// replacement that doesn't add a ton of extra code as of writing this.
# pragma warning(suppress : 4996)
# ifdef _MSC_VER
# pragma warning(suppress : 4996)
GetVersionEx(&ovi);
# else
GetVersionEx(&ovi);
# endif
snprintf(windowsVersion, sizeof(windowsVersion), "%d.%d",
(int)ovi.dwMajorVersion, (int)ovi.dwMinorVersion);
#endif