简体   繁体   English

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

[英]gcc Error: “Inputtools.c:85: error: conflicting types for ‘strcasestr’”

I tried compiling ADPACK, written in C, on an Intel Mac running OX 10.6.4. 我尝试在运行OX 10.6.4的Intel Mac上编译用C编写的ADPACK。 I got the following error from the make command. 我从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

I tried recasting the size_t as a integer variable, as it is my understanding that size_t pretty much stores an untyped int, but the casting didn't work. 我尝试将size_t重铸为整数变量,因为据我了解,size_t几乎存储了一个无类型的int,但是转换无效。 Has anyone encountered such an error before? 有人遇到过这样的错误吗? Should I try using a different version of gcc? 我应该尝试使用其他版本的gcc吗?

Thanks. 谢谢。 Edited. 编辑。 strcasestr is defined on line 85 as: static char* strcasestr( char *str1, const char *str2) strcasestr在第85行上定义为:static char * strcasestr(char * str1,const char * str2)

It is defined in string.h as char *strcasestr(const char *, const char *); 在string.h中定义为char * strcasestr(const char *,const char *);

Use the %z modifier , if available , eg 使用%z 修饰符如果可用) ,例如

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

See: How can one print a size_t variable portably using the printf family? 请参阅: 如何使用printf系列可移植地打印size_t变量? (possible duplicate) for details (可能重复)以获取详细信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM