
Originally Posted by
AMAMH
thanks MK27 for ur reply.
u really helped me, especially for pointing that I should use -Wall to disable gnu extensions, but isn't gcc available for all operating systems?
This doesn't actually disable them; it is just to let you know. If you are using the GNU C library with your compiler, you can use strcasestr. What that message ("warning: implicit declaration of function") usually means is that you don't have a prototype defined for your function -- which makes it slightly confusing, so try to remember this!
To make a long story short, if you run across that warning because of a library function (not your own*) and you want to get rid of it and still compile with -Wall, just copy the prototype from the manual into your program code at the top:
Code:
char * strcasestr (const char *haystack, const char *needle);
Now you can compile with -Wall and there will be no warnings. I don't know how or why gcc uses this method. It seems to me:
warning: strcasestr is a GNU specific extension to the C standard
would have been fine. In any case, "forcing" you to copy the prototype in does serve as a strong reminder of the fact that that function may have limited portability.
There are actually not many functions like that, strcasestr is the only one I could think of off the top of my head.
And yes, gcc is available for available for more OS's than I've ever heard of. I don't think it has to use the GNU C library to work; certainly MS users use it and they are not using the GNU library. It is good you are thinking pro-actively, but don't sweat about this stuff too much right now.
* if it's because of your own function you forgot to include a prototype: that is the original meaning of "warning: implicit declaration..."