Skip to content

Commit fbcafe9

Browse files
committed
Add extra checks for limits.h header when building with gcc.
1 parent 5a5195a commit fbcafe9

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,30 @@
99
#ifndef __LLVM_LIBC_MACROS_LIMITS_MACROS_H
1010
#define __LLVM_LIBC_MACROS_LIMITS_MACROS_H
1111

12+
#if __has_include_next(<limits.h>)
13+
1214
// Suppress `#include_next is a language extension` warnings.
1315
#ifdef __clang__
1416
#pragma clang diagnostic push
1517
#pragma clang diagnostic ignored "-Wgnu-include-next"
16-
#else // gcc
18+
#elif defined(__GNUC__) // gcc
19+
#if !defined _GCC_LIMITS_H_
20+
#define _GCC_LIMITS_H_
21+
#endif
1722
#pragma GCC system_header
18-
#endif // __clang__
23+
#endif // __clang__, __GNUC__
1924

25+
// Include compiler's header
2026
#include_next <limits.h>
2127

2228
#ifdef __clang__
2329
#pragma clang diagnostic pop
2430
#endif // __clang__
2531

32+
#endif // __has_include_next(<limits.h>)
33+
34+
// Supplement missing macros.
35+
2636
#ifndef CHAR_BIT
2737
#ifdef __CHAR_BIT__
2838
#define CHAR_BIT __CHAR_BIT__

0 commit comments

Comments
 (0)