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. ArchiveDisclaimer


The WritableElementsLength property specifies either the number of elements of an array or a buffer pointed to by a pointer that can be legally written. This property is allowed on Pre and Post conditions and can be used on pointer or array data types.

The value of this property is specified in terms of another buffer parameter. The number of elements in the buffer parameter is used to determine the actual number of valid elements of an array or of a buffer pointed to by a pointer.

The following code shows how to set the value of the WritableElementsLength property using a buffer parameter:

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

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