[libc-commits] [PATCH] D158128: [libc] [NFC] explain compiler macros in limits.h

Alfred Persson Forsberg via Phabricator via libc-commits libc-commits at lists.llvm.org
Wed Aug 16 16:15:17 PDT 2023


alfredfo created this revision.
Herald added projects: libc-project, All.
Herald added a subscriber: libc-commits.
alfredfo requested review of this revision.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D158128

Files:
  libc/include/llvm-libc-macros/limits-macros.h


Index: libc/include/llvm-libc-macros/limits-macros.h
===================================================================
--- libc/include/llvm-libc-macros/limits-macros.h
+++ libc/include/llvm-libc-macros/limits-macros.h
@@ -1,6 +1,12 @@
 #ifndef __LLVM_LIBC_MACROS_LIMITS_MACROS_H
 #define __LLVM_LIBC_MACROS_LIMITS_MACROS_H
 
+// Normally compiler headers will be prefered over LLVM-libc headers and
+// include_next this header, however, during LLVM-libc build itself the
+// LLVM-libc headers are prefered, and to get C numerical limits we need to
+// include compiler (freestanding) limits.h. The macro checks are here to avoid
+// including limits.h when compiler headers have already been included.
+
 #if !defined _GCC_LIMITS_H_ && !defined __CLANG_LIMITS_H &&                    \
     __has_include_next(<limits.h>)
 #include_next <limits.h>


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D158128.550928.patch
Type: text/x-patch
Size: 852 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230816/8699d079/attachment.bin>


More information about the libc-commits mailing list