Dela via


C6518

warning C6518: annotation conflict: WritableElementsConst and WritableBytesConst may not be specified on buffers that are not writable

This warning indicates that a conflict exists between Access property value and a writable property. This ordinarily indicates that a writable property does not have write access to the parameter being annotated.

Example

The following code generates this warning because the Access property does not allow write access:

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

void f([SA_Pre(Deref=1, Access=SA_Read)][SA_Pre(WritableElementsConst =9)] char* pc);

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

void f([Pre(Deref=1, Access=Read)][Pre(WritableElementsConst=9)] char* pc);

To correct this warning, allow writable access to the parameter, as shown in the following code:

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

void f([SA_Pre(Deref=1, Access=SA_Write)][SA_Pre(WritableElementsConst =9)] char* pc);

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

void f([Pre(Deref=1, Access=Write)][Pre(WritableElementsConst=9)] char* pc);

See Also

Other Resources

Annotation Properties