I installed clang with Visual Studio and then built the highlighted project as it's said in the documentation.
The build was successful, however when I try this:
clang -cc1 -analyze -analyzer-checker=core.DivideZero test.c
It says:
test.c:1:10: fatal error: 'stdio.h' file not found
#include <stdio.h>
^~~~~~~~~
1 error generated.
I tried many suggestions but nothing worked.
However if I do something like this it works
clang --analyze text.c
I don't know if this uses all the available checkers. I need to write my own checker and test it...
Any ideas?
Output of clang --version
clang version 7.0.0 (trunk 322536)
Target: i686-pc-windows-msvc
Thread model: posix
InstalledDir: C:\path\build\Debug\bin
Yes, I have an idea. Remove -cc1
or <stdio.h>
. According to the clang FAQ this is your error. It states quite explicitly, giving your precise example:
$ clang -cc1 hello.c hello.c:1:10: fatal error: 'stdio.h' file not found #include <stdio.h> ^ 1 error generated.
Reading on, it gives other alternative solutions, as well as a useful explanation, which you should certainly read in its entirety, since it's our job as programmers to read the manuals for the technology we use.
clang -cc1
is the frontend,clang
is the driver. The driver invokes the frontend with options appropriate for your system. To see these options, run:$ clang -### -c hello.c
Some
clang
command line options are driver-only options, some are frontend-only options. Frontend-only options are intended to be used only by clang developers. Users should not runclang -cc1
directly, because-cc1
options are not guaranteed to be stable.If you want to use a frontend-only option (“a
-cc1
option”), for example-ast-dump
, then you need to take theclang -cc1
line generated by the driver and add the option you need. Alternatively, you can runclang -Xclang <option> ...
to force the driver pass<option>
toclang -cc1
.
The emphasis is mine. This should give you enough guidance to get what you need done.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With