[libcxx-commits] [PATCH] D79888: libc++: include unistd.h if available to get some preprocessor macros

Mara Sophie Grosch via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed May 13 10:50:33 PDT 2020


LittleFox94 created this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.
LittleFox94 added a comment.

Since this include was deleted as "dead code" before, I added a comment why it is not dead


Including unistd.h allows the systems default headers to define some more preprocessor macros we might need for configuration.

This fixes a check for newlib, see https://bugs.llvm.org/show_bug.cgi?id=45862


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79888

Files:
  libcxx/include/__config


Index: libcxx/include/__config
===================================================================
--- libcxx/include/__config
+++ libcxx/include/__config
@@ -10,6 +10,11 @@
 #ifndef _LIBCPP_CONFIG
 #define _LIBCPP_CONFIG
 
+#if __has_include(<unistd.h>)
+// include unistd.h if available for some preprocessor defines like _NEWLIB_VERSION
+#  include <unistd.h>
+#endif
+
 #if defined(_MSC_VER) && !defined(__clang__)
 #  if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #    define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79888.263776.patch
Type: text/x-patch
Size: 521 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20200513/0e7500cf/attachment.bin>


More information about the libcxx-commits mailing list