Dela via


C6517

warning C6517: annotation conflict: ValidElementsConst and ValidBytesConst may not be specified on the buffers that are not readable

This warning indicates that ValidElementsConst and ValidBytesConst properties do not have the required read access. You cannot use these properties to annotate a parameter without providing read access.

Example

The following code generates this warning because read access is not granted on the buffer:

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

To correct this warning, grant read access as shown in the following code:

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

See Also

Other Resources

Annotation Properties