Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clang stdio,h file not found

Tags:

c

clang

stdio

I installed clang with Visual Studio and then built the highlighted project as it's said in the documentation.

enter image description here

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
like image 336
UnguruBulan Avatar asked Jan 21 '18 17:01

UnguruBulan


1 Answers

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 run clang -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 the clang -cc1 line generated by the driver and add the option you need. Alternatively, you can run clang -Xclang <option> ... to force the driver pass <option> to clang -cc1.

The emphasis is mine. This should give you enough guidance to get what you need done.

like image 119
autistic Avatar answered Sep 28 '22 17:09

autistic