Clang stdio,找不到 h 文件

标签 c clang stdio

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

enter image description here

构建成功,但是当我尝试这样做时:

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.

我尝试了很多建议,但没有任何效果。

但是,如果我这样做,它会起作用

clang --analyze text.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> .根据the clang FAQ这是你的错误。它非常明确地说明了您的确切示例:

$ clang -cc1 hello.c
hello.c:1:10: fatal error: 'stdio.h' file not found
#include <stdio.h>
         ^
1 error generated.

继续阅读,它提供了其他替代解决方案以及有用的解释,您当然应该完整阅读这些内容,因为阅读我们所用技术的手册是我们作为程序员的工作。

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.

重点是我的。这应该会为您提供足够的指导来完成您需要完成的工作。

关于Clang stdio,找不到 h 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48369566/

相关文章:

python - 如何让我的自定义 shell 与 ssh 一起工作?

c - 如何使用文件描述符刷新写入?

c - 如何让 child 等待 parent 返回(而不是退出)然后自杀?

c++ - 传递 Lambda 时,Visual Studio 2017 中的什么扩展消除了 "bool"与 "std::function"的歧义?

c - 类型转换 : double to char: multiple questions

c++ - 铛AST转储不显示一些全局变量

c - Wait() 运行两次?

c - postgres SQLSTATE : PQresultErrorField returns NULL

c - 编辑距离矩阵

node.js - 是否可以推送文本来提示输入?