headers: crt: allow blocking some APIs in winstore builds Based on this documentation some APIs are not allowed in UWP builds https://docs.microsoft.com/en-us/cpp/cppcx/crt-functions-not-supported-in-universal-windows-platform-apps?view=vs-2019 The documentation is old and may not apply to Win10 but it's still the one listed for UCRT compatibility : https://docs.microsoft.com/en-us/cpp/c-runtime-library/compatibility?view=vs-2019 Define _CRT_USE_WINAPI_FAMILY_DESKTOP_APP to let the compiler know the API's are allowed. So we can restrict some C runtime APIs based on the target family. Signed-off-by: Liu Hao <lh_mouse@126.com>
diff --git a/mingw-w64-headers/crt/corecrt.h b/mingw-w64-headers/crt/corecrt.h index 8f9f6b4..80572c2 100644 --- a/mingw-w64-headers/crt/corecrt.h +++ b/mingw-w64-headers/crt/corecrt.h
@@ -491,6 +491,17 @@ #define __crt_typefix(ctype) #endif +#ifndef _CRT_USE_WINAPI_FAMILY_DESKTOP_APP +#ifdef WINAPI_FAMILY +#include <winapifamily.h> +#if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP) +#define _CRT_USE_WINAPI_FAMILY_DESKTOP_APP +#endif +#else /* !WINAPI_FAMILY */ +#define _CRT_USE_WINAPI_FAMILY_DESKTOP_APP +#endif /* !WINAPI_FAMILY */ +#endif /* _CRT_USE_WINAPI_FAMILY_DESKTOP_APP */ + #ifndef __WIDL__ #pragma pack(pop) #endif