我有一个带有 ANSI C 代码的 Visual Studio Windows 控制台应用程序。 main 函数定义类似于:
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. Thereforeint main (void)
is permitted.
关于c - 如何抑制 int main(void) 函数的 PC-Lint Note 970?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48805249/