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. I got the following error from the make command.
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开发者_如何学Go_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. Has anyone encountered such an error before? Should I try using a different version of gcc?
Thanks. Edited. strcasestr is defined on line 85 as: static char* strcasestr( char *str1, const char *str2)
It is defined in string.h as char *strcasestr(const char *, const char *);
Use the %z
modifier, if available, e.g.
printf( "%zu\n", sizeof( foo ) );
See: How can one print a size_t variable portably using the printf family? (possible duplicate) for details
精彩评论