How to: Annotate C++ Code
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

How to: Annotate C++ Code

To annotate code in C++, you first include the SourceAnnotations.h file and then use the vc_attributes namespace.

To annotate code in C++

  1. Add the #include <CodeAnalysis/SourceAnnotations.h> file to your project header file.

  2. Next, add the using namespace vc_attributes; statement.


After adding the include file and the namespace, you annotate C++ code as shown in the following code:

// MyCode.h
#include <CodeAnalysis/SourceAnnotations.h>
using namespace vc_attributes;
class CMyClass
       void f ( [Pre ( Valid = Yes )] int *pWidth );
// code ...

// MyCode.cpp
#include "MyCode.h"
void CMyClass::f ( [Pre (Valid = Yes)] int pWidth )

In C, you must use the SA_ prefix for enumerated property values. In C++, SA_ prefix is optional.

See Also

Other Resources

Annotation Properties

© 2016 Microsoft