如何排除pclint中的一些“unable to open include file *.h”错误

问题描述 投票:0回答:2

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

无法打开包含文件 *.h

我不想在 std.lnt 文件中抑制这个错误,我不想在 include 语句之前添加

-elint errorcode
。请建议我有什么方法可以抑制 std.lnt 文件中的特定头文件。

c include header-files lint pc-lint
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)

1
投票

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

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

然后确保在使用 PC-Lint 检查代码时定义

PLATFORM_PC
,这样它就永远不会看到它不理解的平台的包含。

© www.soinside.com 2019 - 2024. All rights reserved.