C6501
The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.
The latest version of this topic can be found at C6501.
warning C6501: annotation conflict: <name> property conflicts with previously specified property
This warning occurs only in code that is using a deprecated version of the source-code annotation language (SAL). We recommend that you port your code to use the latest version of SAL. For more information, see Using SAL Annotations to Reduce C/C++ Code Defects. |
This warning indicates the presence of conflicting properties in the annotation. This typically occurs when multiple properties that serve similar purpose are used to annotate a parameter or return value. To correct the warning, you must choose the property that best addresses your need.
The following code generates this warning because both ValidElementsConst and ValidBytesConst provide a mechanism to allow valid data to be read:
// C #include <CodeAnalysis\SourceAnnotations.h> void fd([SA_Pre(ValidElementsConst =4, ValidBytesConst =4)] char pch[]); // C++ #include <CodeAnalysis\SourceAnnotations.h> using namespace vc_attributes; void f( [Pre(ValidElementsConst=4, ValidBytesConst=4 )] char pch[] );
To correct this warning, use the most appropriate property, as shown in the following code:
// C #include <CodeAnalysis\SourceAnnotations.h> void f( [SA_Pre(ValidElementsConst=4)] char pch[] ); // C++ #include <CodeAnalysis\SourceAnnotations.h> using namespace vc_attributes; void f( [Pre(ValidElementsConst=4)] char pch[] );