C6535

警告 C6535:缓冲区的大小不能为 <n>,大于 max(size_t)

此警告指示缓冲区的大小不能大于 size_t。 size_t 类型被定义为无符号整数,它的实际大小与系统有关。

示例

在下面的代码示例中,因为对只能接受 size_t 类型的 ValidBytes 使用了 __int64,所以会生成此警告:

// C
#include <CodeAnalysis\SourceAnnotations.h>
void f ([SA_Pre(ValidBytes="c")] char *pc, __int64 c);

// C++
#include <CodeAnalysis\SourceAnnotations.h>
using namespace vc_attributes;
void f ([Pre(ValidBytes="c")] char *pc, __int64 c);

若要更正此警告,请对大小使用正确的数据类型,如下面的代码示例所示:

// C
#include <CodeAnalysis\SourceAnnotations.h>
void f ([SA_Pre(ValidBytes="c")] char *pc, size_t c);

// C++
#include <CodeAnalysis\SourceAnnotations.h>
using namespace vc_attributes;
void f ([Pre(ValidBytes="c")] char *pc, size_t c);

ValidBytes 属性不能应用于函数指针。