embedded_guy
embedded_guy

Reputation: 1977

How do I suppress Lint messages in regards to anonymous structs?

I am running PC-Lint 8.00x on code similar to the following:

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 returns the following error messages:

Error 40: Undeclared identifier 'blue'

Error 63: Expected an lvalue

The code compiles and runs as expected. I am assuming this is because of the anonymous struct, is that assumption correct? If so, how can I suppress these messages for this particular circumstance? I currently suppress messages in the "options.lnt" file as our local coding practice prohibits putting comments directly in the code to suppress Lint messages.

Upvotes: 0

Views: 3294

Answers (1)

embedded_guy
embedded_guy

Reputation: 1977

As I was posting this I recalled that once upon a time I had set the +fan flag and thought that should have covered this case. I decided to take another look at the PC Lint documentation and quickly discovered that flag only suppresses warning regarding anonymous unions.

I needed to set the +fas flag in my "options.lnt" file as well.

After running PC Lint again, all of the warnings I was concerned about were suppressed. The warnings were, in fact, due to the anonymous struct.

Upvotes: 2

Related Questions