<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/116554>116554</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
`-nostdinc++` on Windows doesn't seem to work
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
BluTree
</td>
</tr>
</table>
<pre>
I have a case where I want to disable C++ standard library includes, to only use system headers and C standard library as follows:
```cpp
#include <iostream>
#include <stdio.h>
int main(int argc, char** argv)
{
printf("Hello World");
return 0;
}
```
For this, I use `-nostdinc++` to have errors when including c++ headers (in this case, iostream).
But on Windows, this doesn't seem to change anything. When looking at the search paths by invoking clang with verbose output, I have these includes:
```
C:\Dev\Sources\C++ tests>clang++ src/test.cc -nostdinc++ -o test.exe --verbose
clang version 19.1.3
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: C:\Dev\LLVM\bin
"C:\\Dev\\LLVM\\bin\\clang++.exe" -cc1 -triple x86_64-pc-windows-msvc19.41.34120 -emit-obj -mincremental-linker-compatible -dumpdir test.exe- -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name test.cc -mrelocation-model pic -pic-level 2 -mframe-pointer=none -relaxed-aliasing -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic "-fdebug-compilation-dir=C:\\Dev\\Sources\\C++ tests" -v "-fcoverage-compilation-dir=C:\\Dev\\Sources\\C++ tests" -nostdinc++ -resource-dir "C:\\Dev\\LLVM\\lib\\clang\\19" -internal-isystem "C:\\Dev\\LLVM\\lib\\clang\\19\\include" -internal-isystem "C:\\Dev\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.41.34120\\include" -internal-isystem "C:\\Dev\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.41.34120\\atlmfc\\include" -internal-isystem "C:\\Windows Kits\\10\\Include\\10.0.22621.0\\ucrt" -internal-isystem "C:\\Windows Kits\\10\\Include\\10.0.22621.0\\shared" -internal-isystem "C:\\Windows Kits\\10\\Include\\10.0.22621.0\\um" -internal-isystem "C:\\Windows Kits\\10\\Include\\10.0.22621.0\\winrt" -internal-isystem "C:\\Windows Kits\\10\\Include\\10.0.22621.0\\cppwinrt" -fdeprecated-macro -ferror-limit 19 -fmessage-length=175 -fno-use-cxa-atexit -fms-extensions -fms-compatibility -fms-compatibility-version=19.41.34120 -std=c++14 -fskip-odr-check-in-gmf -fdelayed-template-parsing -fcxx-exceptions -fexceptions -fcolor-diagnostics -faddrsig -o "C:\\Users\\Aubin\\AppData\\Local\\Temp\\test-91f9da.o" -x c++ src/test.cc
clang -cc1 version 19.1.3 based upon LLVM 19.1.3 default target x86_64-pc-windows-msvc
#include "..." search starts here:
#include <...> search starts here:
C:\Dev\LLVM\lib\clang\19\include
C:\Dev\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\include
C:\Dev\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\atlmfc\include
C:\Windows Kits\10\Include\10.0.22621.0\ucrt
C:\Windows Kits\10\Include\10.0.22621.0\shared
C:\Windows Kits\10\Include\10.0.22621.0\um
C:\Windows Kits\10\Include\10.0.22621.0\winrt
C:\Windows Kits\10\Include\10.0.22621.0\cppwinrt
End of search list.
"C:\\Dev\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.41.34120\\bin\\Hostx64\\x64\\link.exe" -out:test.exe -defaultlib:libcmt -defaultlib:oldnames "-libpath:C:\\Dev\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.41.34120\\lib\\x64" "-libpath:C:\\Dev\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.41.34120\\atlmfc\\lib\\x64" "-libpath:C:\\Windows Kits\\10\\Lib\\10.0.22621.0\\ucrt\\x64" "-libpath:C:\\Windows Kits\\10\\Lib\\10.0.22621.0\\um\\x64" "-libpath:C:\\Dev\\LLVM\\lib\\clang\\19\\lib\\windows" -nologo "C:\\Users\\Aubin\\AppData\\Local\\Temp\\test-91f9da.o"
```
These paths aren't impacted at all by `-nostdinc++`.
Invoking clang with `-nostdinc` work without issue:
```
C:\Dev\Sources\C++ tests>clang++ src/test.cc -nostdinc -o test.exe --verbose
clang version 19.1.3
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: C:\Dev\LLVM\bin
"C:\\Dev\\LLVM\\bin\\clang++.exe" -cc1 -triple x86_64-pc-windows-msvc19.41.34120 -emit-obj -mincremental-linker-compatible -dumpdir test.exe- -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name test.cc -mrelocation-model pic -pic-level 2 -mframe-pointer=none -relaxed-aliasing -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic "-fdebug-compilation-dir=C:\\Dev\\Sources\\C++ tests" -v "-fcoverage-compilation-dir=C:\\Dev\\Sources\\C++ tests" -nostdsysteminc -nobuiltininc -resource-dir "C:\\Dev\\LLVM\\lib\\clang\\19" -fdeprecated-macro -ferror-limit 19 -fmessage-length=175 -fno-use-cxa-atexit -fms-extensions -fms-compatibility -fms-compatibility-version=19.41.34120 -std=c++14 -fskip-odr-check-in-gmf -fdelayed-template-parsing -fcxx-exceptions -fexceptions -fcolor-diagnostics -faddrsig -o "C:\\Users\\Aubin\\AppData\\Local\\Temp\\test-4edf30.o" -x c++ src/test.cc
clang -cc1 version 19.1.3 based upon LLVM 19.1.3 default target x86_64-pc-windows-msvc
#include "..." search starts here:
End of search list.
src/test.cc:1:10: fatal error: 'iostream' file not found
1 | #include <iostream>
| ^~~~~~~~~~
1 error generated.
```
But as it removes every search path, I need to manually add them.
When looking from the default system search paths, it should remove the first search path.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzs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