Recognize `-nostdinc`, `-nostdinc++` & friends for Clang and GCC
0x6675636b796f75676974687562 opened this issue · 0 comments
There're 3 categories of standard headers:
- The standard C library
- The standard C++ library
- Compiler-specific built-in headers
The -no...inc
switches have the following meaning in Clang and GCC:
Switch | Included headers, C (-xc ) |
Included headers, C++ (-xc++ ) |
---|---|---|
-nostdinc |
Empty list | C++ (Clang) or empty list (GCC) |
-nostdinc++ |
C, compiler built-in | C, compiler built-in |
-nostdlibinc |
Compiler built-in only | Compiler built-in only |
-nobuiltininc |
C | C, C++ |
The one-liner to find out the built-in include directories:
${CC} ${CFLAGS} -v -E -o- - </dev/null 2>&1 >/dev/null | grep -F '#include <...> search starts here:' -A 99 | grep '^\s' | xargs -rn1 realpath | sort -u
CFLAGS
must specify the language (-xc
or -xc++
) and, optionally, may include -nostdinc
and/or nostdinc++
.
GCC
C (-xc
)
Default (no directories excluded)
Standard C library and compiler built-in includes:
/usr/include
/usr/include/x86_64-linux-gnu
/usr/lib/gcc/x86_64-linux-gnu/10/include
/usr/local/include
-nostdinc
Empty list.
-nostdinc++
Standard C library and compiler built-in includes:
/usr/include
/usr/include/x86_64-linux-gnu
/usr/lib/gcc/x86_64-linux-gnu/10/include
/usr/local/include
C (-xc++
)
Default (no directories excluded)
Standard C and C++ library and compiler built-in includes:
/usr/include
/usr/include/c++/10
/usr/include/c++/10/backward
/usr/include/x86_64-linux-gnu
/usr/include/x86_64-linux-gnu/c++/10
/usr/lib/gcc/x86_64-linux-gnu/10/include
/usr/local/include
-nostdinc
Empty list.
-nostdinc++
Standard C library and compiler built-in includes:
/usr/include
/usr/include/x86_64-linux-gnu
/usr/lib/gcc/x86_64-linux-gnu/10/include
/usr/local/include
Clang
C (-xc
)
Default (no directories excluded)
Standard C library and compiler built-in includes:
/usr/include
/usr/include/x86_64-linux-gnu
/usr/lib/llvm-11/lib/clang/11.0.1/include
/usr/local/include
-nostdinc
Empty list.
-nostdinc++
Standard C library and compiler built-in includes:
/usr/include
/usr/include/x86_64-linux-gnu
/usr/lib/llvm-11/lib/clang/11.0.1/include
/usr/local/include
-nostdlibinc
Compiler built-in includes:
/usr/lib/llvm-11/lib/clang/11.0.1/include
-nobuiltininc
Standard C library includes:
/usr/include
/usr/include/x86_64-linux-gnu
/usr/local/include
C (-xc++
)
Default (no directories excluded)
Standard C and C++ library and compiler built-in includes:
/usr/include
/usr/include/c++/10
/usr/include/c++/10/backward
/usr/include/x86_64-linux-gnu
/usr/include/x86_64-linux-gnu/c++/10
/usr/lib/llvm-11/lib/clang/11.0.1/include
/usr/local/include
-nostdinc
Standard C++ library includes:
/usr/include/c++/10
/usr/include/c++/10/backward
/usr/include/x86_64-linux-gnu/c++/10
-nostdinc++
Standard C library and compiler built-in includes:
/usr/include
/usr/include/x86_64-linux-gnu
/usr/lib/llvm-11/lib/clang/11.0.1/include
/usr/local/include
-nostdlibinc
Compiler built-in includes:
/usr/lib/llvm-11/lib/clang/11.0.1/include
-nobuiltininc
Standard C and C++ library includes:
/usr/include
/usr/include/c++/10
/usr/include/c++/10/backward
/usr/include/x86_64-linux-gnu
/usr/include/x86_64-linux-gnu/c++/10
/usr/local/include