我在类似于以下的代码上运行 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 blue;
blue = (unsigned char)my_color.blue; /* Lint messages occur here */
PC-Lint 返回以下错误消息:
Error 40: Undeclared identifier 'blue'
Error 63: Expected an lvalue
代码按预期编译和运行。 我假设这是因为匿名结构,这个假设是否正确?如果是这样,我该如何在这种特殊情况下抑制这些消息? 我目前禁止在“options.lnt”文件中显示消息,因为我们的本地编码实践禁止将注释直接放在代码中以禁止 Lint 消息。