On Fri, 17 Apr 2020, Steve Lhomme wrote:
On 2020-04-16 21:38, Martin Storsjö wrote:
On Thu, 16 Apr 2020, Steve Lhomme wrote:
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
---
mingw-w64-headers/crt/corecrt.h | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/mingw-w64-headers/crt/corecrt.h
b/mingw-w64-headers/crt/corecrt.h
index 8f9f6b42..76bb2ebe 100644
--- a/mingw-w64-headers/crt/corecrt.h
+++ b/mingw-w64-headers/crt/corecrt.h
@@ -491,6 +491,13 @@ typedef struct threadlocaleinfostruct {
#define __crt_typefix(ctype)
#endif
+#include <winapifamily.h>
+#if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_APP)
+#define _CRT_ALLOW_API_FAMILY_APP
+#elif WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP)
+#define _CRT_ALLOW_API_FAMILY_DESKTOP
+#endif
This doesn't seem right.
If WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP, then
WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) is true, and
_CRT_ALLOW_API_FAMILY_DESKTOP never gets defined.
You're right. WINAPI_FAMILY_DESKTOP_APP matches both. So only
_CRT_ALLOW_API_FAMILY_APP is defined.
The goal of _CRT_ALLOW_API_FAMILY_APP is to only select API's allowed
for "apps" (WINAPI_PARTITION_APP), so the opposite of what
WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_APP) provides. In the end I
don't use it.
So I only need to define _CRT_ALLOW_API_FAMILY_DESKTOP which should be
defined when we're not in WINAPI_FAMILY_APP. But the
WINAPI_FAMILY_PARTITION() macro doesn't allow selecting only
WINAPI_FAMILY_APP.
So in the end I need to switch the code to define
_CRT_ALLOW_API_FAMILY_APP and then hide some API's when it's defined.
So you mean there's functions that are only available when WINAPI_FAMILY
strictly is set to WINAPI_FAMILY_APP, despite the fact that
WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) is set even when targeting
desktop? Which ones is that? The vast majority of "functions you should
use when targeting the app subset" is available in desktop mode as well.
Btw why do you need to add this custom define at all - can't the crt code
just use WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) like the
platform headers?
// Martin
_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public