Export (0) Print
Expand All
3 out of 3 rated this helpful - Rate this topic

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

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.