4

我在我的项目中使用 PC lint。我的项目兼容在 windows 和 linux 中构建。所以我在我的项目中使用了 windows 头文件(visualstudio)文件和 linux 头文件(gcc)。我正在为所有文件完全运行 pclint。它给出错误信息

无法打开包含文件 *.h

我不想在 std.lnt 文件中抑制这个错误,我不想添加

-elint 错误代码
在包含语句之前。请建议我有什么方法可以抑制 std.lnt 文件中的特定头文件。

4

2 回答 2

2

我假设您并没有真正收到消息

Unable to open include file *.h

但真的得到消息

Unable to open include file fred.h

对于一些文件fred.h。

如果我是正确的,那么将这两行添加到 std.lnt:

-efile(322,fred.h)
-efile(7,fred.h)
于 2011-04-21T12:24:28.100 回答
1

使用与平台相关的预处理器符号保护相关包含:

#if defined PLATFORM_PC
#include <whatever/is/needed.h>
#else if defined PLATFORM_POSIX
#include <stdio.h>
#endif

然后确保PLATFORM_PC在使用 PC-Lint 检查代码时进行定义,以便它永远不会看到它不理解的平台的包含。

于 2011-04-21T12:30:34.257 回答