smeenai created this revision.

Some CRT APIs are unavailable for Windows Store apps [1]. Detect when
we're targeting the Windows Store and don't try to refer to non-existent
CRT functions in that case. (This would otherwise lead to a compile
error when using the libc++ headers and compiling for Windows Store.)

[1] 
https://docs.microsoft.com/en-us/cpp/cppcx/crt-functions-not-supported-in-universal-windows-platform-apps


https://reviews.llvm.org/D31737

Files:
  include/__config
  include/cstdlib


Index: include/cstdlib
===================================================================
--- include/cstdlib
+++ include/cstdlib
@@ -130,8 +130,10 @@
 using ::atexit;
 using ::exit;
 using ::_Exit;
+#ifndef _LIBCPP_WINDOWS_STORE_APP
 using ::getenv;
 using ::system;
+#endif
 using ::bsearch;
 using ::qsort;
 using ::abs;
Index: include/__config
===================================================================
--- include/__config
+++ include/__config
@@ -211,6 +211,16 @@
 # if defined(_LIBCPP_MSVCRT)
 #   define _LIBCPP_HAS_QUICK_EXIT
 # endif
+
+// Some CRT APIs are unavailable to store apps
+#if defined(WINAPI_FAMILY)
+#include <winapifamily.h>
+#if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) &&                      
\
+    (!defined(WINAPI_PARTITION_SYSTEM) ||                                      
\
+     !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_SYSTEM))
+#define _LIBCPP_WINDOWS_STORE_APP
+#endif
+#endif
 #endif // defined(_WIN32)
 
 #ifdef __sun__


Index: include/cstdlib
===================================================================
--- include/cstdlib
+++ include/cstdlib
@@ -130,8 +130,10 @@
 using ::atexit;
 using ::exit;
 using ::_Exit;
+#ifndef _LIBCPP_WINDOWS_STORE_APP
 using ::getenv;
 using ::system;
+#endif
 using ::bsearch;
 using ::qsort;
 using ::abs;
Index: include/__config
===================================================================
--- include/__config
+++ include/__config
@@ -211,6 +211,16 @@
 # if defined(_LIBCPP_MSVCRT)
 #   define _LIBCPP_HAS_QUICK_EXIT
 # endif
+
+// Some CRT APIs are unavailable to store apps
+#if defined(WINAPI_FAMILY)
+#include <winapifamily.h>
+#if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) &&                      \
+    (!defined(WINAPI_PARTITION_SYSTEM) ||                                      \
+     !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_SYSTEM))
+#define _LIBCPP_WINDOWS_STORE_APP
+#endif
+#endif
 #endif // defined(_WIN32)
 
 #ifdef __sun__
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
  • [PATCH] D31737: [libc++] Res... Shoaib Meenai via Phabricator via cfe-commits

Reply via email to