Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

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.

Example

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); 

See Also

Other Resources

Annotation Properties

Community Additions

ADD
Show:
© 2015 Microsoft