WritableElements

更新:2007 年 11 月

WritableElements 属性指定指针指向的数组或缓冲区的可以合法写入的元素数目。Pre 和 Post 属性 (Attribute) 上允许此属性 (Property),此属性 (Property) 可以在指针或数组数据类型上使用。此属性的值是一个表达式,其中涉及到另一个参数,该参数指定可写入元素的实际数目。大小参数的类型可以是 size_t 范围内的任何整型。该参数包含可写入元素的实际数目。

示例

下面的代码演示如何使用 WritableElements 属性:

// C
#include <CodeAnalysis\SourceAnnotations.h>
void f ([SA_Pre(WritableElements="c")] char *pc, size_t c);
// use of dereference operator
void f ([SA_Pre(WritableElements="*c")] char *pc, size_t *c);

// C++
#include <CodeAnalysis\SourceAnnotations.h>
using namespace vc_attributes;
void f ([Pre(WritableElements="c")] char *pc, size_t c);
// use of dereference operator
void f ([Pre(WritableElements="*c")] char *pc, size_t *c);

请参见

概念

批注概述

其他资源

批注属性