If you are using winnt.h in
any of its manifestations prior to Visual C++ Version 6 then you
may have trouble turning off Error 18. You may also have trouble
turning off Warning 624 even with a version of winnt.h as
late as Visual C++ 6. Although winnt.h originates with Microsoft
it finds its way into many other compiler's suite of header
files such as those offered by Borland and Watcom.
Here is a run-down on problems introduced by winnt.h and what you can do about them.
1. Error 18 problem.
There is a sequence in early winnt.h files that goes as follows:
/*lint -e18 */ // Don't complain about different definitions
// DWORD ExceptionCode;
/*lint +e18 */ // Resume checking for different definitions
Clearly this should have been:
/*lint -save -e18 */ // Don't complain about different definitions
// DWORD ExceptionCode;
/*lint -restore */ // Resume checking for different definitions
Workaround:
If you are editing winnt.h ,
you can make the change cited above, or eliminate the lint comments
altogether as Microsoft has done with their Version 6 of Visual C++.
If you do not wish to edit winnt.h (which is
understandable) you can employ the option:
-esym(18,Symbol-name)
where, of course, Symbol-name is replaced by a
suitable name. This will suppress the error
for the named symbol. Since the Symbol-name
can contain wild-card characters you may even use:
-esym(18,*)
2. Message 624
There is a pair of lines in all versions of winnt.h
as follows:
/*lint -e624 */
/*lint +e624 */
This looks like an old effort to suppress a
warning about a typedef being redeclared (to
be something different) in another module.
The effect, as in the case of Error 18 above,
is to turn on Warning 624 even if it had been
turned off.
If you are editing winnt.h you should delete both
lines as they are clearly intended as a NO-OP.
If you are not editing winnt.h you can employ the option
-esym(624,Symbol-name)
As in the case of Error 18 above, wild cards can be
used to suppress all 624's as follows:
-esym(624,*)
3. macro turn-on of Warnings 527 and 530.
There is a sequence of three macros that when used
have the effect of turning on Warnings 527
and 530 even if they had previously been turned off:
#define UNREFERENCED_PARAMETER(P) \
/*lint -e527 -e530 */ \
{ \
(P) = (P); \
} \
/*lint +e527 +e530 */
#define DBG_UNREFERENCED_PARAMETER(P) \
/*lint -e527 -e530 */ \
{ \
(P) = (P); \
} \
/*lint +e527 +e530 */
#define DBG_UNREFERENCED_LOCAL_VARIABLE(V) \
/*lint -e527 -e530 */ \
{ \
(V) = (V); \
} \
/*lint +e527 +e530 */
These macros exhibit the same problem that was
exhibited in the earlier examples involving
Error 18 and Warning 624. Clearly these
should have been:
#define UNREFERENCED_PARAMETER(P) \
/*lint -save -e527 -e530 */ \
{ \
(P) = (P); \ } \
/*lint -restore */
#define DBG_UNREFERENCED_PARAMETER(P) \
/*lint -save -e527 -e530 */ \
{ \
(P) = (P); \
} \
/*lint -restore */
#define DBG_UNREFERENCED_LOCAL_VARIABLE(V) \
/*lint -save -e527 -e530 */ \
{ \
(V) = (V); \
} \
/*lint -restore */
As a work-around if you do not choose to edit
winnt.h, is to use the -emacro option as
follows.
-emacro(527,UNREFERENCED_PARAMETER,
,DBG_UNREFERENCED_PARAMETER,
,DBG_UNREFERENCED_LOCAL_VARIABLE)
-emacro(530,UNREFERENCED_PARAMETER,
,DBG_UNREFERENCED_PARAMETER,
,DBG_UNREFERENCED_LOCAL_VARIABLE)
These
have the effect of placing an additional
wrapper around the original macro but it does no harm.
This might also have been a slightly better way to
implement the original suppression.