gcc错误:“Inputtools.c:85:错误:'strcasestr'的冲突类型”

时间:2010-09-27 19:12:55

标签: c macos gcc

我尝试在运行OX 10.6.4的Intel Mac上编译用C语言编写的ADPACK。我从make命令中得到以下错误。

gcc -I/usr/local/include -I/home/ozaki/include -c adpack.c
adpack.c: In function ‘main’:
adpack.c:223: warning: incompatible implicit declaration of built-in function ‘strlen’
gcc -I/usr/local/include -I/home/ozaki/include -c Inputtools.c
Inputtools.c:85: error: conflicting types for ‘strcasestr’
/usr/include/string.h:88: error: previous declaration of ‘strcasestr’ was here
Inputtools.c: In function ‘strcasestr’:
Inputtools.c:96: warning: cast from pointer to integer of different size
Inputtools.c:96: warning: cast from pointer to integer of different size
Inputtools.c: In function ‘input_cmpstring’:
Inputtools.c:124: warning: format ‘%d’ expects type ‘int’, but argument 2 has type     ‘size_t’
Inputtools.c:124: warning: format ‘%d’ expects type ‘int’, but argument 3 has type     ‘size_t’
make: *** [Inputtools.o] Error 1

我尝试将size_t重新设置为整数变量,因为我的理解是size_t几乎存储了一个无类型的int,但是转换不起作用。有没有人遇到过这样的错误?我应该尝试使用不同版本的gcc吗?

感谢。编辑。 strcasestr在第85行定义为: static char * strcasestr(char * str1,const char * str2)

它在string.h中定义为 char * strcasestr(const char *,const char *);

1 个答案:

答案 0 :(得分:3)

使用%z 修饰符(如果有),例如

printf( "%zu\n", sizeof( foo ) );

有关详细信息,请参阅:How can one print a size_t variable portably using the printf family?(可能重复)