Export (0) Print
Expand All

C6521

warning C6521: invalid size specification: * operator can only be applied to pointer types

This warning indicates an incorrect use of the * operator in an annotation property that accepts the size of a parameter in terms of another parameter. This warning is generated if the size parameter is a non-pointer type and a * operator is used to dereference it. However, you can use the * operator if the size parameter is passed as pointer type.

The following code generates this warning:

// C
#include <CodeAnalysis\SourceAnnotations.h>
void f ([SA_Pre(WritableElements="*c")] char *pc, size_t c);

// C++
#include <CodeAnalysis\SourceAnnotations.h>
using namespace vc_attributes;
void f ([Pre(WritableElements="*c")] char *pc, size_t c);

To correct this warning, either delete the * operator from the WritableElements property value or pass a pointer to size_t. The following code uses size_t *c:

// C
#include <CodeAnalysis\SourceAnnotations.h>
void f ([SA_Pre(WritableElements="*c")] char *pc, size_t *c);

// C++
#include <CodeAnalysis\SourceAnnotations.h>
using namespace vc_attributes;
void f ([Pre(WritableElements="*c")] char *pc, size_t *c); 

Community Additions

ADD
Show:
© 2014 Microsoft