Hello all, To my understanding, the header _mingw_mac.h allows users to define the macro __MINGW_MSVC_COMPAT_WARNINGS to receive warnings for using functions that MSVC would consider deprecated or unsafe. And if that macro is defined, the _CRT_NONSTDC_NO_DEPRECATE or _CRT_SECURE_NO_WARNINGS macros can additionally be defined to disable warnings for functions MSVC considers deprecated or unsafe, respectively.
So if I wanted to enable warnings for functions MSVC considers deprecated, but not for functions MSVC considers unsafe, I would define both __MINGW_MSVC_COMPAT_WARNINGS and _CRT_SECURE_NO_WARNINGS. However, when compiling for C, doing so fails to disable the 'unsafe functions' warnings, as if _CRT_SECURE_NO_WARNINGS wasn't defined. Here's what seems to be the relevant code (_mingw_mac.h, line 273): > #if !defined (_CRT_SECURE_NO_WARNINGS) || > (_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES == 0) > # define __MINGW_ATTRIB_DEPRECATED_SEC_WARN \ > __MINGW_ATTRIB_DEPRECATED_STR(__MINGW_SEC_WARN_STR) > #else > # define __MINGW_ATTRIB_DEPRECATED_SEC_WARN > #endif Warnings are only disabled if both _CRT_SECURE_NO_WARNINGS is defined and _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES is not 0. The _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES macro (when defined as 1) allows for MSVC-considered unsafe functions to be overloaded with the secure versions of those functions [1]. So it does make some sense to emit warnings when the user hasn't enabled this feature. However, this feature can only be used in C++, since C doesn't allow for function overloading. As such, when using C, _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES will always be either 0 or undefined (which preprocessor expressions evaluate to 0). This makes it impossible to disable warnings for specifically MSVC-considered unsafe functions when compiling for C. This bug can likely be fixed by only considering _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES if __cplusplus is defined (i.e. if compiling for C++ rather than C), by just not considering _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES at all, or something similar. [1] https://learn.microsoft.com/en-us/cpp/c-runtime-library/secure-template-overloads Sincerely, Seth McDonald. PGP Fingerprint 82B9 620E 53D0 A1AE 2D69 6111 C267 B002 0A90 0289
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public