c - 如何抑制 int main(void) 函数的 PC-Lint Note 970?

标签 c c99 misra ansi-c pc-lint

我有一个带有 ANSI C 代码的 Visual Studio Windows 控制台应用程序。 ma​​in 函数定义类似于:

int main(void)
{
    // do stuff
    return 0;
}

但是,PC-Lint 针对 int 类型报告以下消息

Note 970: Use of modifier or type ⁡int⁢ outside of a typedef [MISRA 2012 Directive 4.6, advisory]

我需要同时保留 main 函数和 Note 970 的 int 类型。因此,我只想为 main 函数定义抑制 Note 970。我不想在源代码上加上//lint !e970。

我想知道是否可以仅针对带有 PC-Lint 选项的 main 函数的定义抑制此消息。

最佳答案

你的工具坏了,向 PC Lint 报告错误。

引用 MISRA-C:2012 指令 4.6:

Exceptions:

For function main an int may be used rather than the typedefs as a return type. Therefore int main (void) is permitted.

关于c - 如何抑制 int main(void) 函数的 PC-Lint Note 970?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48805249/

相关文章:

C : Multithreading using ucontext/Floating point exception(core dumped)

c++ - 获取整数位集中前导 1 位置的最快方法?

c - 更好地理解 c 中可变参数的类型提升

c - 指针 MISRA 违规的算术

c++ - 是否有要求 float 而不是 double 的 printf 说明符?

int 的 C 命令行参数

c - 当与 ARM 目标上的数字文字结合时,Clang 是否将短裤提升为整数?

c - 套接字连接()与绑定(bind)()

c - GCC 属性对嵌套函数的影响

c - MISRA 13.5 关于非编译示例的问题