Export (0) Print
Expand All

C6506

warning C6506: invalid annotation: <name> property may only be used on values of pointer or array types

This warning indicates that a property is used on a type other than pointer or array types. The Access, Tainted, and Valid properties can be used on all data types. Other properties, such as ValidBytesConst, ValidElementsConst, ElementSize, and NullTerminted support pointer, pointer to members, or array types. For a complete list of properties and the supported data types, see Annotation Properties.

The following code generates this warning:

// C
#include <CodeAnalysis\SourceAnnotations.h>
void f([SA_Pre(ValidElementsConst=4)] int x);

// C++
#include <CodeAnalysis\SourceAnnotations.h>
using namespace vc_attributes;

void f([Pre(ValidElementsConst=4)] int x);

To correct this warning, use a pointer or an array type, as shown in the following sample code:

// C
#include <CodeAnalysis\SourceAnnotations.h>
void f([SA_Pre(ValidElementsConst=4)] int *px);
 - or -
void f([SA_Pre(ValidElementsConst=4)] int px[]);

// C++
#include <CodeAnalysis\SourceAnnotations.h>
using namespace vc_attributes;
void f([Pre(ValidElementsConst=4)] int *px);
 - or -
void f([Pre(ValidElementsConst=4)] int px[]);

Reference

Community Additions

ADD
Show:
© 2014 Microsoft