C6517

更新:2007 年 11 月

警告 C6517:批注冲突: 不能在不可读的缓冲区上指定 ValidElementsConst 和 ValidBytesConst

此警告意味着 ValidElementsConst 和 ValidBytesConst 属性没有所需的读取权限。如果不提供读取权限,则不能使用这些属性来对参数进行批注。

示例

在下面的代码中,因为没有在缓冲区上授予读取权限,所以会生成此警告:

// C
#include <CodeAnalysis\SourceAnnotations.h>
void f([SA_Pre(ValidBytesConst=10 )][SA_Pre( Deref=1, Access=SA_Write )] char* buffer );

// C++
#include <CodeAnalysis\SourceAnnotations.h>
using namespace vc_attributes;

void f([Pre( ValidBytesConst=10 )][Pre( Deref=1, Access=Write )] char* buffer );

若要更正此警告,请授予读取权限,如下面的代码所示:

// C
#include <CodeAnalysis\SourceAnnotations.h>

void f([SA_Pre(ValidBytesConst=10 )][SA_Pre( Deref=1, Access=SA_ReadWrite )] char* buffer ); 

// C++
#include <CodeAnalysis\SourceAnnotations.h>
using namespace vc_attributes;

void f([Pre( ValidBytesConst=10 )][Pre( Deref=1, Access=ReadWrite )] char* buffer ); 

请参见

其他资源

批注属性