Skip to content

Commit

Permalink
Remove use of include_next from c++ headers
Browse files Browse the repository at this point in the history
Using include_next bypasses the default header search path and lets
files later in the include path take priority over earlier files.

This makes replacing libc impossible as the default libc headers will
occur after the libstdc++ headers, and so be picked up in place of
headers inserted at the begining of the search path or appended to the
end of the search path.

Using include_next is a hack to work-around broken combinations of
libraries, and is not necessary in a well constructed toolchain.

Signed-off-by: Keith Packard <keithp@keithp.com>
  • Loading branch information
keith-packard authored and Lapshin committed Aug 2, 2024
1 parent d973d59 commit f0d8b3a
Show file tree
Hide file tree
Showing 21 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions libstdc++-v3/include/bits/std_abs.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
#include <bits/c++config.h>

#define _GLIBCXX_INCLUDE_NEXT_C_HEADERS
#include_next <stdlib.h>
#include <stdlib.h>
#ifdef __CORRECT_ISO_CPP_MATH_H_PROTO
# include_next <math.h>
# include <math.h>
#endif
#undef _GLIBCXX_INCLUDE_NEXT_C_HEADERS

Expand Down
2 changes: 1 addition & 1 deletion libstdc++-v3/include/c/cassert
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@
#pragma GCC system_header

#include <bits/c++config.h>
#include_next <assert.h>
#include <assert.h>
2 changes: 1 addition & 1 deletion libstdc++-v3/include/c/cctype
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@

#pragma GCC system_header

#include_next <ctype.h>
#include <ctype.h>

#endif
2 changes: 1 addition & 1 deletion libstdc++-v3/include/c/cerrno
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#pragma GCC system_header

#include <bits/c++config.h>
#include_next <errno.h>
#include <errno.h>

// Adhere to section 17.4.1.2 clause 5 of ISO 14882:1998
#ifndef errno
Expand Down
2 changes: 1 addition & 1 deletion libstdc++-v3/include/c/cfloat
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@
#pragma GCC system_header

#include <bits/c++config.h>
#include_next <float.h>
#include <float.h>

#endif
2 changes: 1 addition & 1 deletion libstdc++-v3/include/c/climits
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@
#pragma GCC system_header

#include <bits/c++config.h>
#include_next <limits.h>
#include <limits.h>

#endif
2 changes: 1 addition & 1 deletion libstdc++-v3/include/c/clocale
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@

#pragma GCC system_header

#include_next <locale.h>
#include <locale.h>

#endif
2 changes: 1 addition & 1 deletion libstdc++-v3/include/c/cmath
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

#include <bits/c++config.h>

#include_next <math.h>
#include <math.h>

// Get rid of those macros defined in <math.h> in lieu of real functions.
#undef abs
Expand Down
2 changes: 1 addition & 1 deletion libstdc++-v3/include/c/csetjmp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

#pragma GCC system_header

#include_next <setjmp.h>
#include <setjmp.h>

// Get rid of those macros defined in <setjmp.h> in lieu of real functions.
#undef longjmp
Expand Down
2 changes: 1 addition & 1 deletion libstdc++-v3/include/c/csignal
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@

#pragma GCC system_header

#include_next <signal.h>
#include <signal.h>

#endif
2 changes: 1 addition & 1 deletion libstdc++-v3/include/c/cstdarg
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@
#pragma GCC system_header

#undef __need___va_list
#include_next <stdarg.h>
#include <stdarg.h>

#endif
2 changes: 1 addition & 1 deletion libstdc++-v3/include/c/cstddef
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@
#define __need_ptrdiff_t
#define __need_NULL
#define __need_offsetof
#include_next <stddef.h>
#include <stddef.h>

#endif
2 changes: 1 addition & 1 deletion libstdc++-v3/include/c/cstdio
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

#pragma GCC system_header

#include_next <stdio.h>
#include <stdio.h>

// Get rid of those macros defined in <stdio.h> in lieu of real functions.
#undef clearerr
Expand Down
2 changes: 1 addition & 1 deletion libstdc++-v3/include/c/cstdlib
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@

#pragma GCC system_header

#include_next <stdlib.h>
#include <stdlib.h>

#endif
2 changes: 1 addition & 1 deletion libstdc++-v3/include/c/cstring
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@

#pragma GCC system_header

#include_next <string.h>
#include <string.h>

#endif
2 changes: 1 addition & 1 deletion libstdc++-v3/include/c/ctime
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@

#pragma GCC system_header

#include_next <time.h>
#include <time.h>

#endif
2 changes: 1 addition & 1 deletion libstdc++-v3/include/c/cuchar
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#include <cwchar>

#if _GLIBCXX_USE_C11_UCHAR_CXX11
# include_next <uchar.h>
# include <uchar.h>
#endif

#endif // C++11
Expand Down
2 changes: 1 addition & 1 deletion libstdc++-v3/include/c/cwchar
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#include <ctime>

#if _GLIBCXX_HAVE_WCHAR_H
#include_next <wchar.h>
#include <wchar.h>
#endif

// Need to do a bit of trickery here with mbstate_t as char_traits
Expand Down
2 changes: 1 addition & 1 deletion libstdc++-v3/include/c/cwctype
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include <bits/c++config.h>

#if _GLIBCXX_HAVE_WCTYPE_H
#include_next <wctype.h>
#include <wctype.h>
#endif

#endif
2 changes: 1 addition & 1 deletion libstdc++-v3/include/c_global/cmath
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
#include <bits/cpp_type_traits.h>
#include <ext/type_traits.h>
#define _GLIBCXX_INCLUDE_NEXT_C_HEADERS
#include_next <math.h>
#include <math.h>
#undef _GLIBCXX_INCLUDE_NEXT_C_HEADERS
#include <bits/std_abs.h>

Expand Down
2 changes: 1 addition & 1 deletion libstdc++-v3/include/c_global/cstdlib
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ namespace std
// Need to ensure this finds the C library's <stdlib.h> not a libstdc++
// wrapper that might already be installed later in the include search path.
#define _GLIBCXX_INCLUDE_NEXT_C_HEADERS
#include_next <stdlib.h>
#include <stdlib.h>
#undef _GLIBCXX_INCLUDE_NEXT_C_HEADERS
#include <bits/std_abs.h>

Expand Down

0 comments on commit f0d8b3a

Please sign in to comment.