Udostępnij za pośrednictwem


C6526

warning C6526 - invalid size specification: expression must be of array or pointer type

This warning indicates that an incorrect data type is used to specify a property value. A property might support all data types or a subset of them. In this case, the value specified for the property must be an array or a pointer type. For a list of annotation properties, see Annotation Properties.

Example

The following code generates this warning because the value for WritableElementsLenght must be specified by using an array or a pointer type:

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

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

To correct this warning, the following code sets the value of WritableELementsLength to a pointer type. By specifying an array or a pointer type, you are indicating that the length of char *ps is the same as the length of char*pt.

// C
#include <CodeAnalysis\SourceAnnotations.h>
void f ([SA_Pre(WritableElementsLength="pt")] char *ps, char *pt);

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