What am I doing wrong in this lint error suppression attempt? And is there a better way?

Bob Vesterman picture Bob Vesterman · May 22, 2014 · Viewed 9.4k times · Source

I have the following line of code:

ftDCB.ByteSize = FT_BITS_8;

And lint (PC-lint via Visual Lint, specifically) gives me a message 1924 on it ("C-style cast -- More Effective C++ #2").

FT_BITS_8 is #defined in a third party header file, and there's where the cast is:

#define FT_BITS_8           (UCHAR) 8

And UCHAR is a typedef from another third party header file:

typedef unsigned char UCHAR;

The thing it's being assigned to (ftDCB.ByteSize) is a BYTE, which is also a typedef for an unsigned char:

typedef unsigned char       BYTE;

I don't really want to modify the third-party headers, so I tried to suppress the message in my code:

//lint -e(1924) C-style cast
ftDCB.ByteSize = FT_BITS_8;

But I get the same 1924 message.

What am I doing wrong here? And is there a cleaner way to do what I want to accomplish (other than modifying the third-party header)?

Answer

Bob Vesterman picture Bob Vesterman · May 22, 2014

OK, answering my own question, the following seems to work:

ftDCB.ByteSize = /*lint -e(1924) C-style cast */ FT_BITS_8;