C6512

更新:2007 年 11 月

警告 C6512:无效的批注: 如果 Valid 属性为 No,Null 属性必须为 Maybe

此警告意味着 Null 被视为有效值;因此,Null 不能与 Valid 属性值 No 一起使用。

示例

下面的代码生成此警告:

// C
#include <CodeAnalysis\SourceAnnotations.h>
void f([SA_Pre(Null=SA_Yes, Valid=SA_No)] char *pc);

// C++
#include <CodeAnalysis\SourceAnnotations.h>
using namespace vc_attributes;
void f([Pre(Null=Yes, Valid=No)] char *pc);

若要更正此警告,请使用下面的代码:

// C
#include <CodeAnalysis\SourceAnnotations.h>
void f([SA_Pre(Null=SA_Yes, Valid=SA_Maybe)] char *pc);
-or-
void f([SA_Pre(Null=SA_Yes, Valid=SA_Yes)] char *pc);

// C++
#include <CodeAnalysis\SourceAnnotations.h>
using namespace vc_attributes;
void f([Pre(Null=Yes, Valid=Maybe)] char *pc);
- or-
void f([Pre(Null=Yes, Valid=Yes)] char *pc);