Dela via


C6504

warning C6504: invalid annotation: property may only be used on values of pointer, pointer-to-member, or array type

This warning indicates the use of a property on an incompatible data type. For more information about data types supported by properties, see Annotation Properties.

Example

The following code generates this warning because Null property cannot be used on char data type. The reason that this occurs is because Deref=1 refers to characters, and not the pointer to the characters:

// C
#include <CodeAnalysis\SourceAnnotations.h>
void f([SA_Pre(Deref=1, Null=SA_Yes)] char* pc);

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

void f([Pre(Deref=1, Null=Yes)] char* pc);

To correct this warning, remove Deref=1, as shown in the following sample code:

// C
#include <CodeAnalysis\SourceAnnotations.h>
void f([SA_Pre(Null=SA_Yes)] char* pc);

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

void f([Pre(Null=Yes)] char *pc); 

The defective code shown earlier also generates warning C6516 because property conflicts resulted in an invalid annotation.