Skip to content

Commit

Permalink
[libc++] Respect Windows Store app CRT restrictions
Browse files Browse the repository at this point in the history
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

Differential Revision: https://reviews.llvm.org/D31737

llvm-svn: 299625
  • Loading branch information
smeenai committed Apr 6, 2017
1 parent be65893 commit 5dc5a8e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
10 changes: 10 additions & 0 deletions libcxx/include/__config
Expand Up @@ -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__
Expand Down
2 changes: 2 additions & 0 deletions libcxx/include/cstdlib
Expand Up @@ -130,8 +130,10 @@ using ::abort;
using ::atexit;
using ::exit;
using ::_Exit;
#ifndef _LIBCPP_WINDOWS_STORE_APP
using ::getenv;
using ::system;
#endif
using ::bsearch;
using ::qsort;
using ::abs;
Expand Down

0 comments on commit 5dc5a8e

Please sign in to comment.