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.


The ElementSizeConst property specifies the size of an element in bytes. This property is allowed on Pre and Post attributes and can only be applied to pointer or array data types. The ElementSizeConst property must be used in conjunction with any one of the following properties:

  • ValidElements

  • ValidElementsLength

  • ValidElementsConst

  • WritableElements

  • WritableElementsConst

  • WritableElementsLength

The value of ElementSizeConst property is a constant of type size_t. To specify an element size that depends on the value of another parameter to the function, use ElementSize property.

The following code shows that the size of each element is 4 bytes, and the number of valid elements is three:

// C 
#include <CodeAnalysis\SourceAnnotations.h>
void f([SA_Pre(Deref=0, Null=SA_No, ElementSizeConst=4, ValidElementsConst=3)] char pc[]);

// C++
#include <CodeAnalysis\SourceAnnotations.h>
using namespace vc_attributes;
void f([Pre(Deref=0, Null=No, ElementSizeConst=4, ValidElementsConst=3)] char pc[]);

C6513 is issued if the ElementSizeConst property is used alone.

Community Additions

© 2015 Microsoft