铛静态分析器找不到stdio.h

召唤

我正在尝试在一个非常简单的程序上使用Clang静态分析器:

#include <stdio.h>
main ()
{
    printf("Hello, world !");
}

当我做

lang helloworld.c

它会成功编译程序。


当我做

lang -cc1 -analyze -analyzer-checker = unix helloworld.c

它引发一个错误:

helloworld.c:1:10: fatal error: 'stdio.h' file not found
#include <stdio.h>
         ^
1 error generated.

铛--analyze -Xanalyzer -analyzer-checker = unix helloworld.c

什么都不打印。


有什么问题,我该如何解决?我假设静态分析器看不到头文件,尽管编译器可以使用它们。请帮我。

Nishant Sharma

有时检查器无法读取默认的包含路径。因此,您可能希望将其作为参数传递。您可以使用以下命令找到clang所查看的确切包含路径:

clang -E -x c - -v < /dev/null

然后您的最终查询将变为:

clang -I<path to include> --analyze -Xanalyzer -analyzer-checker=unix helloworld.c

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章