找不到clang stdio,h文件 [英] Clang stdio,h file not found

查看:261
本文介绍了找不到clang stdio,h文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用Visual Studio安装了clang,然后按照文档中的说明构建了突出显示的项目。

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

它说:

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...

有什么想法吗?

<$的输出c $ c> clang --version

clang version 7.0.0 (trunk 322536)
Target: i686-pc-windows-msvc
Thread model: posix
InstalledDir: C:\path\build\Debug\bin


推荐答案

是的,我有个主意。删除 -cc1 < stdio.h> 。根据 c常见问题解答,这是您的错误。它非常明确地陈述了您的例子:

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 是前端, clang 是驱动程序。驱动程序使用适合您系统的选项来调用前端。要查看这些选项,请运行:

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

某些 clang 命令行选项仅是驱动程序选项,有些是仅前端的选项选项。仅前端选项仅供clang开发人员使用。 用户不应直接运行 clang -cc1 ,因为不能保证 -cc1 选项的稳定性。

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.

如果您想使用仅前端选项( a -cc1 选项),例如 -ast-dump ,则需要使用驱动程序生成的 clang -cc1 行,并添加您需要的选项。或者,您可以运行 clang -Xclang< option> ... 迫使驾驶员将< option> 传递给 clang -cc1

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.

这篇关于找不到clang stdio,h文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆