C6387
警告 C6387: <argument> 會是 <value>: 這並未遵守函式 <function name> 的規格: 行: x, y
如果正傳遞給加註之函式參數的值是未預期的值,則會引發這則警告。 例如,將可能是 null 的值傳遞給以 [Pre( Null=No )] 屬性 (Attribute) 所標記的參數,會產生這則警告。
範例
下列程式碼會因為將 null 參數傳遞給 f(char *),而產生這則警告:
#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