Share via


C6513

warning C6513: invalid annotation: ElementSizeConst requires additional size properties

Note

This warning occurs only in code that is using a deprecated version of the source-code annotation language (SAL). We recommend that you port your code to use the latest version of SAL. For more information, see Using SAL Annotations to Reduce C/C++ Code Defects.

This warning indicates that ElementSizeConst requires other properties that are missing from the annotation. Specifying ElementSizeConst alone does not provide any benefit to the analysis process. In addition to specifying ElementSize, other properties such as ValidElementsConst or WritableElementsConst must also be specified.

Example

The following code generates this warning:

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

// C++
#include <CodeAnalysis\SourceAnnotations.h>
using namespace vc_attributes;
void f([Pre(ElementSizeConst=4)] void* pc);

To correct this warning, use the following code:

// C
#include <CodeAnalysis\SourceAnnotations.h>
void f ([SA_Pre(ElementSizeConst=4, ValidElementsConst=2)] void* pc);

// C++
#include <CodeAnalysis\SourceAnnotations.h>
using namespace vc_attributes;
void f ([Pre(ElementSizeConst=4, ValidElementsConst=2)] void* pc);

Incorrect use of ElementSize property also generates this warning.

See Also

Other Resources

[NIB]Annotation Properties