memcmp的隐式声明在c99中无效

memcmp的隐式声明在c99中无效

问题描述:

我在Xcode 4中创建了一个非常基本的C控制台应用程序,并且在编译时遇到了一个警告:Implicit declaration of memcmp is invalid in c99memcmp的隐式声明在c99中无效

我该功能的使用是你所期望的:

if(memcmp(buf, block, 0x14) != 0) 
{ 
    fclose(fh); 
    printf("invalid file: %s\n", argv[argc-1]); 
    return 1; 
} 

如何使用功能错误的,我怎么能去修复它?

+1

它实际上在C89/C90中也是未定义的行为。您应该*总是*'#include'适用于您使用的任何库函数的适当头文件。 –

您忘记了#include <string.h>,其中包含声明memcmp