Share via


ValidElements

ValidElements 속성은 올바르게 읽을 수 있는 배열 또는 포인터가 가리키는 버퍼의 요소 수를 지정합니다. 이 속성은 Pre 및 Post 특성에서 포인터나 배열 데이터 형식에 사용할 수 있습니다. 이 속성의 값은 유효한 요소의 실제 개수를 지정하는 다른 매개 변수가 포함된 식입니다.

예제

다음 코드에서는 ValidElements 속성을 사용하는 방법을 보여 줍니다.

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

// The keyword 'return' is used to indicate the return value,
// which in this case is the number of valid elements.
[returnvalue:SA_Post(MustCheck=SA_Yes)]int f([SA_Post(ValidElements="return")] char *pc);

// C++
#include <CodeAnalysis\SourceAnnotations.h>
using namespace vc_attributes; 
void f([Pre(ValidElements="count") ] char *pc, size_t count);

// The keyword 'return' is used to indicate the return value,
// which in this case is the number of valid elements.
[returnvalue:Post(MustCheck=Yes)]int f([Post(ValidElements="return")] char *pc);

참고 항목

개념

주석 개요

기타 리소스

주석 속성