PREfast Warning Message Reference (Windows CE 5.0)

Send Feedback

This section describes the warning messages produced by PREfast. You can view these messages by category or number:

Each warning topic in this guide contains a detailed description of the warning, including examples and additional resources whenever possible.

Suppressing Individual Warning Messages

PREfast includes support for pragma prefast, which enables source-level suppression of specific PREfast warnings.

You can use pragma prefast to suppress individual warnings when PREfast reports an incorrect or irrelevant message.

Because pragma prefast is an extension to the PREfast AST compiler, it is not recognized by other compilers, including the C++ compiler included with Visual C++ 6.0 and later.

This results in a 4068 warning. This warning can cause builds to fail under -W4 -Wx flags.

Using pragma prefast

To use pragma prefast build problems, add the following to a header that is used in all your source files:

#ifndef _PREFAST_
#pragma warning(disable:4068)
#endif

The syntax of pragma prefast is

#pragma prefast(
    specifier {: warning number list separated by whitespace}
    (, " comment field description")

The following example suppresses a warning 308 on the next statement. The comment field allows arbitrary strings, useful for describing why the message is suppressed.

#pragma prefast(suppress:308, "the pointer was saved above (PREfast bug 508)")

There are several specifier options available in addition to suppress.

Specifier Example Description
disable
#pragma prefast(disable:1 11 221, "explanation for the disable") 
Disables the PREfast warnings specified in a warning list.
enable
#pragma prefast(enable:1 11 221, "explanation for the enable") 
Enables the PREfast warnings specified in a warning.
push
#pragma prefast(push) 
Pushes the current disabled/enabled state of all the PREfast warnings into a stack.

Similar to #pragma warning(push).

pop
#pragma prefast(pop) 
Resets the disabled/enabled state of all the PREfast warnings to the state of the matching prefast(push) statement.
suppress
5 MyFunction(i, 
#pragma prefast(suppress: 1, "PREfast noise: pftbug-401") 
6 j);
Suppresses the warnings in the next line after the suppress statement.

In this example, PREfast warning 1 on line 6 is suppressed.

See Also

PREfast Overview

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.