So given the following code:
typedef enum
{
myenum_a = 1,
myenum_b = 2,
myenum_c = 3,
myenum_max = 4
}myenum_t;
then later
myenum_t test;
switch (test)
{
case myenum_a:
{
// do stuff
}
case myenum_b:
{
// do stuff
}
case myenum_c:
default:
{
// do stuff
}
}
When I run lint on this I get error 788: "'myenum_max' not used within defaulted switch".
I know I can use "// !e788" to ignore this rule for this particular switch statement, but that means:
Or I can remove the rule entirely with "// -e788", but:
What I really want, but not sure how to do it (or if it exists) is to ignore the rule for a given enum something like:
typedef enum
{
myenum_a = 1,
myenum_b = 2,
myenum_c = 3,
myenum_max = 4 // !eXXX - ignore this enum
}myenum_t;
Is that possible?
PC-Lint does not provide a special command to suppress messages regarding enum values, BUT it provides the option -estring(#, string)
to suppress a specific error message containing the specified string. This can be used for suppressing specific messages on specific enum values.
For your example this should work:
//lint -estring(788, myenum_max)
The option -estring(#, string)
has been introduced with PC-Lint version 9.00.