WritableElementsLength

WritableElementsLength 属性指定指针指向的数组或缓冲区的可以合法写入的元素数目。Pre 和 Post 条件上允许此属性,此属性可以在指针或数组数据类型上使用。

此属性的值用另一个缓冲区参数指定。 缓冲区参数中的元素数目用于确定指针指向的数组或缓冲区中有效元素的实际数目。

示例

下面的代码演示如何使用缓冲区参数设置 WritableElementsLength 属性的值:

// 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[]);

请参见

概念

批注概述

其他资源

批注属性