C 如何抑制匿名结构的Lint消息?
我在类似于以下代码的代码上运行PC Lint 8.00x:C 如何抑制匿名结构的Lint消息?,c,lint,pc-lint,C,Lint,Pc Lint,我在类似于以下代码的代码上运行PC Lint 8.00x: typedef union { struct { unsigned int blue : 5; unsigned int green : 6; unsigned int red : 5; }; unsigned short color_value; } Color_Type; Color_Type my_color; unsigned char bl
typedef union
{
struct
{
unsigned int blue : 5;
unsigned int green : 6;
unsigned int red : 5;
};
unsigned short color_value;
} Color_Type;
Color_Type my_color;
unsigned char blue;
blue = (unsigned char)my_color.blue; /* Lint messages occur here */
PC Lint返回以下错误消息:
错误40:未声明的标识符“蓝色”
错误63:应为左值
代码按预期编译和运行我假设这是因为匿名结构,这个假设正确吗?如果是,我如何在这种特殊情况下抑制这些消息?我当前抑制“options.lnt”中的消息文件,因为我们的本地编码实践禁止在代码中直接添加注释以抑制Lint消息。当我发布此消息时,我回忆起,从前我设置了
+fan
标志,并认为这应该涵盖此情况。我决定再看一眼PC Lint文档,很快发现这个标志只会抑制关于匿名工会的警告
我还需要在“options.lnt”文件中设置+fas
标志
在再次运行PC Lint之后,我所关心的所有警告都被抑制了。这些警告实际上是由于匿名结构造成的