Code annotations significantly enhance the ability of PREƒast to detect potential bugs while lowering the rate of false positives. Annotations provide PREƒast with information about the intended use of an annotated function, which allows PREƒast to better determine whether a particular bug exists. Annotations do not interfere with normal compilation of source code.
Annotations improve PREƒast results by:
| • | Extending the concept of a function prototype |
| • | Describing the contract between a function and its caller |
| • | Helping to refine a function's design |
| • | Enabling PREƒast to detect more errors with less noise |
PREƒast for Drivers version 8.0 supports analysis of code that uses the general-purpose annotations defined in specstrings.h and the driver-specific annotations defined in Driverspecs.h, which are specifically designed for use in kernel-mode drivers. PREƒast for Drivers version 8.0 is available as a standalone tool in the Windows Driver Kit (WDK) for Windows Vista, starting with the February CTP release. The C/C++ Code Analysis tool in Visual Studio Team System, Team Edition for Developers includes the same functionality (without the specialized driver functionality) using the /analyze option.
This paper provides an overview of annotations and how PREƒast interprets them when analyzing code. Developers can use the information in this paper to plan how to apply annotations to their code and get more precise results from PREƒast.
This information applies for the following operating systems:
Microsoft Windows Vista
Microsoft Windows Server 2008
Important: PREfast driver-specific annotations require WDK build version 6001 or later.
In this white paper:
| • | Introduction to PREƒast Annotations |
| • | How Annotations Improve PREƒast Results |
| • | Where to Place Annotations in Code |
| • | General-Purpose Annotations |
| • | Driver Annotations |
| • | How to Write and Debug Annotations |
| • | PREƒast Annotation Best Practices |
| • | Example: Osrusbfx2.h with Annotations |
See Also