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 ValidBytesConst property specifies the number of bytes of an array or a buffer pointed to by a pointer that can be legally read. This property is allowed on Pre and Post attributes and can only be applied to pointer or array data types.

The value of this property is a constant of type size_t. To specify a number of readable bytes that depends on another parameter to the function, use the ValidBytes property.

The following code shows how to use the ValidBytesConst property:

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

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

Community Additions

© 2015 Microsoft