diff --git a/libcxx/include/complex.h b/libcxx/include/complex.h --- a/libcxx/include/complex.h +++ b/libcxx/include/complex.h @@ -24,13 +24,11 @@ #endif #ifdef __cplusplus - -#include - -#else // __cplusplus - -#include_next - -#endif // __cplusplus +# include +#else +# if __has_include_next() +# include_next +# endif +#endif #endif // _LIBCPP_COMPLEX_H diff --git a/libcxx/include/ctype.h b/libcxx/include/ctype.h --- a/libcxx/include/ctype.h +++ b/libcxx/include/ctype.h @@ -35,7 +35,9 @@ # pragma GCC system_header #endif -#include_next +#if __has_include_next() +# include_next +#endif #ifdef __cplusplus diff --git a/libcxx/include/errno.h b/libcxx/include/errno.h --- a/libcxx/include/errno.h +++ b/libcxx/include/errno.h @@ -28,7 +28,9 @@ # pragma GCC system_header #endif -#include_next +#if __has_include_next() +# include_next +#endif #ifdef __cplusplus diff --git a/libcxx/include/fenv.h b/libcxx/include/fenv.h --- a/libcxx/include/fenv.h +++ b/libcxx/include/fenv.h @@ -56,7 +56,9 @@ # pragma GCC system_header #endif -#include_next +#if __has_include_next() +# include_next +#endif #ifdef __cplusplus diff --git a/libcxx/include/float.h b/libcxx/include/float.h --- a/libcxx/include/float.h +++ b/libcxx/include/float.h @@ -76,7 +76,9 @@ # pragma GCC system_header #endif -#include_next +#if __has_include_next() +# include_next +#endif #ifdef __cplusplus diff --git a/libcxx/include/inttypes.h b/libcxx/include/inttypes.h --- a/libcxx/include/inttypes.h +++ b/libcxx/include/inttypes.h @@ -248,7 +248,9 @@ # define __STDC_FORMAT_MACROS #endif -#include_next +#if __has_include_next() +# include_next +#endif #ifdef __cplusplus diff --git a/libcxx/include/limits.h b/libcxx/include/limits.h --- a/libcxx/include/limits.h +++ b/libcxx/include/limits.h @@ -44,7 +44,11 @@ #endif #ifndef __GNUC__ -#include_next + +# if __has_include_next() +# include_next +# endif + #else // GCC header limits.h recursively includes itself through another header called // syslimits.h for some reason. This setup breaks down if we directly diff --git a/libcxx/include/locale.h b/libcxx/include/locale.h --- a/libcxx/include/locale.h +++ b/libcxx/include/locale.h @@ -43,6 +43,8 @@ # pragma GCC system_header #endif -#include_next +#if __has_include_next() +# include_next +#endif #endif // _LIBCPP_LOCALE_H diff --git a/libcxx/include/math.h b/libcxx/include/math.h --- a/libcxx/include/math.h +++ b/libcxx/include/math.h @@ -297,7 +297,9 @@ # pragma GCC system_header #endif -#include_next +# if __has_include_next() +# include_next +# endif #ifdef __cplusplus diff --git a/libcxx/include/setjmp.h b/libcxx/include/setjmp.h --- a/libcxx/include/setjmp.h +++ b/libcxx/include/setjmp.h @@ -31,7 +31,9 @@ # pragma GCC system_header #endif -#include_next +#if __has_include_next() +# include_next +#endif #ifdef __cplusplus diff --git a/libcxx/include/stdbool.h b/libcxx/include/stdbool.h --- a/libcxx/include/stdbool.h +++ b/libcxx/include/stdbool.h @@ -24,7 +24,9 @@ # pragma GCC system_header #endif -#include_next +#if __has_include_next() +# include_next +#endif #ifdef __cplusplus #undef bool diff --git a/libcxx/include/stddef.h b/libcxx/include/stddef.h --- a/libcxx/include/stddef.h +++ b/libcxx/include/stddef.h @@ -42,7 +42,9 @@ # pragma GCC system_header #endif -#include_next +# if __has_include_next() +# include_next +# endif #ifdef __cplusplus typedef decltype(nullptr) nullptr_t; diff --git a/libcxx/include/stdint.h b/libcxx/include/stdint.h --- a/libcxx/include/stdint.h +++ b/libcxx/include/stdint.h @@ -120,6 +120,8 @@ # define __STDC_CONSTANT_MACROS #endif -#include_next +#if __has_include_next() +# include_next +#endif #endif // _LIBCPP_STDINT_H diff --git a/libcxx/include/stdio.h b/libcxx/include/stdio.h --- a/libcxx/include/stdio.h +++ b/libcxx/include/stdio.h @@ -104,7 +104,9 @@ # pragma GCC system_header #endif -#include_next +# if __has_include_next() +# include_next +# endif #ifdef __cplusplus diff --git a/libcxx/include/stdlib.h b/libcxx/include/stdlib.h --- a/libcxx/include/stdlib.h +++ b/libcxx/include/stdlib.h @@ -90,7 +90,9 @@ # pragma GCC system_header #endif -#include_next +# if __has_include_next() +# include_next +# endif #ifdef __cplusplus extern "C++" { diff --git a/libcxx/include/string.h b/libcxx/include/string.h --- a/libcxx/include/string.h +++ b/libcxx/include/string.h @@ -57,7 +57,9 @@ # pragma GCC system_header #endif -#include_next +#if __has_include_next() +# include_next +#endif // MSVCRT, GNU libc and its derivates may already have the correct prototype in // . This macro can be defined by users if their C library provides diff --git a/libcxx/include/tgmath.h b/libcxx/include/tgmath.h --- a/libcxx/include/tgmath.h +++ b/libcxx/include/tgmath.h @@ -24,13 +24,11 @@ #endif #ifdef __cplusplus - -#include - -#else // __cplusplus - -#include_next - -#endif // __cplusplus +# include +#else +# if __has_include_next() +# include_next +# endif +#endif #endif // _LIBCPP_TGMATH_H diff --git a/libcxx/include/wchar.h b/libcxx/include/wchar.h --- a/libcxx/include/wchar.h +++ b/libcxx/include/wchar.h @@ -120,7 +120,9 @@ #define __CORRECT_ISO_CPP_WCHAR_H_PROTO #endif -#include_next +# if __has_include_next() +# include_next +# endif // Determine whether we have const-correct overloads for wcschr and friends. #if defined(_WCHAR_H_CPLUSPLUS_98_CONFORMANCE_)