[libcxx-commits] [libcxx] [libc++](NFC) fix wrong __has_include (PR #141328)
Tomohiro Kashiwada via libcxx-commits
libcxx-commits at lists.llvm.org
Sat May 24 01:37:34 PDT 2025
kikairoya wrote:
On linux (or most of other systems), this typo is silently treated as header is not found
But, some compiler variant such as MinGW-GCC raises error as invalid filesystem path.
Anyway, `<langinfo.h>` has never been included here.
```
$ uname -ms; gcc -v; clang -v; echo '-------------'; cat test.cc; gcc test.cc; echo '------------------'; clang test.cc
Linux x86_64
組み込み spec を使用しています。
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/15.1.1/lto-wrapper
ターゲット: x86_64-pc-linux-gnu
configure 設定: /build/gcc/src/gcc/configure --enable-languages=ada,c,c++,d,fortran,go,lto,m2,objc,obj-c++,rust,cobol --enable-bootstrap --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://gitlab.archlinux.org/archlinux/packaging/packages/gcc/-/issues --with-build-config=bootstrap-lto --with-linker-hash-style=gnu --with-system-zlib --enable-__cxa_atexit --enable-cet=auto --enable-checking=release --enable-clocale=gnu --enable-default-pie --enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object --enable-libstdcxx-backtrace --enable-link-serialization=1 --enable-linker-build-id --enable-lto --enable-multilib --enable-plugin --enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-pch --disable-werror
スレッドモデル: posix
サポートされている LTO 圧縮アルゴリズム: zlib zstd
gcc バージョン 15.1.1 20250425 (GCC)
clang version 19.1.7
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-pc-linux-gnu/14.2.1
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-pc-linux-gnu/15.1.1
Found candidate GCC installation: /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.2.1
Found candidate GCC installation: /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/15.1.1
Selected GCC installation: /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/15.1.1
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
-------------
#if __has_include("<stdio.h>")
#include <stdio.h>
#endif
int main() {
puts("ok");
}
test.cc: In function ‘int main()’:
test.cc:6:3: エラー: ‘puts’ was not declared in this scope
6 | puts("ok");
| ^~~~
------------------
test.cc:6:3: error: use of undeclared identifier 'puts'
6 | puts("ok");
| ^
1 error generated.
```
```
$ uname -ms; gcc -v; clang -v; echo '-------------'; cat test.cc; gcc test.cc; echo '------------------'; clang test.cc
MINGW64_NT-10.0-19045 x86_64
Using built-in specs.
COLLECT_GCC=D:\msys64\ucrt64\bin\gcc.exe
COLLECT_LTO_WRAPPER=D:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/15.1.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../gcc-15.1.0/configure --prefix=/ucrt64 --with-local-prefix=/ucrt64/local --with-native-system-header-dir=/ucrt64/include --libexecdir=/ucrt64/lib --enable-bootstrap --enable-chec
king=release --with-arch=nocona --with-tune=generic --enable-mingw-wildcard --enable-languages=c,lto,c++,fortran,ada,objc,obj-c++,jit --enable-shared --enable-static --enable-libatomic --enable-thr
eads=posix --enable-graphite --enable-fully-dynamic-string --enable-libstdcxx-backtrace=yes --enable-libstdcxx-filesystem-ts --enable-libstdcxx-time --disable-libstdcxx-pch --enable-lto --enable-li
bgomp --disable-libssp --disable-multilib --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-libiconv --with-system-zlib --with-gmp=/ucrt64 --with-mpfr
=/ucrt64 --with-mpc=/ucrt64 --with-isl=/ucrt64 --with-pkgversion='Rev5, Built by MSYS2 project' --with-bugurl=https://github.com/msys2/MINGW-packages/issues --with-gnu-as --with-gnu-ld --disable-li
bstdcxx-debug --enable-plugin --with-boot-ldflags=-static-libstdc++ --with-stage1-ldflags=-static-libstdc++
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 15.1.0 (Rev5, Built by MSYS2 project)
clang version 20.1.5
Target: x86_64-w64-windows-gnu
Thread model: posix
InstalledDir: D:/msys64/ucrt64/bin
-------------
#if __has_include("<stdio.h>")
#include <stdio.h>
#endif
int main() {
puts("ok");
}
cc1plus.exe: fatal error: <stdio.h>: Invalid argument
compilation terminated.
------------------
test.cc:6:3: error: use of undeclared identifier 'puts'
6 | puts("ok");
| ^
1 error generated.
```
https://github.com/llvm/llvm-project/pull/141328
More information about the libcxx-commits
mailing list