使用稀疏检查C代码

有没有人有稀疏的经验? 我似乎无法find任何文件,所以警告和错误产生我不清楚。 我试图检查邮件列表和手册页,但实际上没有太多。

例如,我在我的一个文件中使用INT_MAX。 这会产生一个错误(未定义的标识符),即使我#include limits.h。

有什么地方可以解释错误和警告吗?

按照说,稀疏不是一个皮棉。 稀疏是为了产生任意代码的分析树,以便进一步分析。

在你的例子中,你要么定义GNU_SOURCE(我相信__GNUC__打开),它将在limits.h中公开你需要的位

我会避免自己定义__GNUC__,因为它激活的几件事情可能会以未定义的方式运行,而没有定义GNU_SOURCE所打开的所有其他开关。

我的观点并不是要帮助你通过错误压缩错误,而是要重申,稀疏主要用作库,而不是作为一个独立的静态分析工具。

从我自己的副本(不知道如果我有当前版本):

This means that a user of the library will literally just need to do struct string_list *filelist = NULL; char *file; action(sparse_initialize(argc, argv, filelist)); FOR_EACH_PTR_NOTAG(filelist, file) { action(sparse(file)); } END_FOR_EACH_PTR_NOTAG(file); and he is now done - having a full C parse of the file he opened. The library doesn't need any more setup, and once done does not impose any more requirements. The user is free to do whatever he wants with the parse tree that got built up, and needs not worry about the library ever again. There is no extra state, there are no parser callbacks, there is only the parse tree that is described by the header files. The action function takes a pointer to a symbol_list and does whatever it likes with it. The library also contains (as an example user) a few clients that do the preprocessing, parsing and type evaluation and just print out the results. These clients were done to verify and debug the library, and also as trivial examples of what you can do with the parse tree once it is formed, so that users can see how the tree is organized. 

包括客户更多的是“功能测试套件和例子”比任何东西。 它是一个非常有用的工具,但是如果你想使用它,你可能会考虑另一个使用角度。 我喜欢它,因为它不使用* lex / bison,这使得它非常容易被破解。

如果你看一下limits.h,你会看到INT_MAX是在这个#if中定义的

 /* If we are not using GNU CC we have to define all the symbols ourself. Otherwise use gcc's definitions (see below). */ #if !defined __GNUC__ || __GNUC__ < 2 

所以为了让它起作用,你应该在包含limits.h之前取消定义__GNUC__