简体   繁体   中英

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_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 , eg

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

See: How can one print a size_t variable portably using the printf family? (possible duplicate) for details

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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