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.

Example

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
{
public:
       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