[libcxx-commits] [PATCH] D86055: [libc++] Fix the wrong usage of __STDC_HOSTED__

hyd-dev via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Aug 17 04:05:36 PDT 2020


hyd-dev created this revision.
hyd-dev added reviewers: __simt__, jfb, ldionne.
hyd-dev added a project: libc++.
Herald added subscribers: libcxx-commits, dexonsmith.
Herald added a reviewer: libc++.
hyd-dev requested review of this revision.

D56913 <https://reviews.llvm.org/D56913> introduced the `_LIBCPP_FREESTANDING` macro and implemented it as:

  #ifndef __STDC_HOSTED__
  #  define _LIBCPP_FREESTANDING
  #endif

However, `__STDC_HOSTED__` is defined as `0` in freestanding implementations instead of undefined [1][2]. This patch corrects the above as:

  #if __STDC_HOSTED__ == 0
  #  define _LIBCPP_FREESTANDING
  #endif

[1]: https://github.com/llvm/llvm-project/blob/cd2139a527f2d829bdde7877c992215f598e927b/clang/lib/Frontend/InitPreprocessor.cpp#L356-L362
[2]: https://en.cppreference.com/w/cpp/preprocessor/replace


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86055

Files:
  libcxx/include/__config


Index: libcxx/include/__config
===================================================================
--- libcxx/include/__config
+++ libcxx/include/__config
@@ -38,7 +38,7 @@
 #  define _LIBCPP_ABI_VERSION 1
 #endif
 
-#ifndef __STDC_HOSTED__
+#if __STDC_HOSTED__ == 0
 #  define _LIBCPP_FREESTANDING
 #endif
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D86055.285955.patch
Type: text/x-patch
Size: 309 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20200817/a5f177d6/attachment.bin>


More information about the libcxx-commits mailing list