C6387

更新:2007 年 11 月

警告 C6387:<argument> 可能是 <value>: 这不符合函数 <function name> 的规范: 行: x, y

如果将意外的值传递给带批注的函数参数,会引发此警告。例如,如果将可能为 null 的值传递给用 [Pre( Null=No )] 属性标记的参数,则会生成此警告。

示例

在下面的代码中,因为向 f(char *) 传递一个 null 参数,所以会生成此警告:

#include <codeanalysis/sourceannotations.h>
using namespace vc_attributes;

[returnvalue:Post(Null=Yes)] char * g();

void f([Pre (Null=No)] char *pch);

void main()
{
    char *pCh=g();
    f(pCh); //C6387
}

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

#include <codeanalysis/sourceannotations.h>
using namespace vc_attributes;

[returnvalue:Post(Null=No)] char * g();

void f([Pre (Null=No)] char *pch);

void main()
{
    char *pCh=g();
    f(pCh);
}

请参见

概念

批注概述

参考

strlen, strlen_l, wcslen, wcslen_l, _mbslen, _mbslen_l, _mbstrlen, _mbstrlen_l