0
votes

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 *);

1
The title points at the wrong error. The actual error that stops the compiler is error: conflicting types for ‘strcasestr’. - kennytm
Could you show us what Inputtools.c is around lines 85, 96 and 124? Otherwise, we're guessing. - David Thornley
As KennyTM says the error is in strcasestr. This function is an extension provided by your compiler (not defined by the Standard) and you're defining another with the same name. Change the name of your function or invoke the compiler in Standard mode. - pmg
Yep, that was it. I changed the name of the function strcasestr, and it works. - notElon

1 Answers

3
votes

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