Are the warnings the same no matter what compiler you use, or are they
compiler specific? I have looked all over the gcc web site, but I can't find
anything that explains what the warnings are.
One more question since I'm writing this. I wrote a piece of code that uses
the "strlen" function as part of a declaration statement:
length = strlen(string1) - 1;
and I get the following warning from gcc:
warning: implicit declaration of function 'strlen'
It compiles and seems to work fine, but I don't understand the warning. If
someone could take the time and help me out and direct me to some info on
this, I'd appriciate it.
You failed to:
#include <string.h>
which is where strlen() is prototyped.
[BTW - this is a question about standard C and would have been better
asked in news:comp.lang.c]
HTH,
--ag
--
Artie Gold -- Austin, Texas
Oh, for the good old days of regular old SPAM.
Think of the answer you least want to hear...
...it's that one!
There's no standardisation for anything in reguard to errors and warnings.
All C (and C++) compilers differ, even across different versions by the
same vendor. In the latter case one would hope they only alter when they
clarify the situation.
Both have FAQ's...
comp.lang.c
alt.comp.lang.learn.c-c++
The gcc implicit declaration warning is actually a good one (you'll be
horrified first time you see any C++ compiler spew out a template error). I
digress, there's extra meaning buried in those words. These two can be
paired off...
implicit/explicit
declaration/definition
...both groups handle the standard C language itself (as opposed to what can
be done with it when you bolt stuff on). Here's an implicit declaration...
/*void foo(void);*/
int
main()
{
foo();
return 0;
}
...remove the comments and you have an explicit declaration. Ignore the
linker error in both cases, foo() doesn't exist inside the libs searched by
the linker whereas strlen() does.
#include <string.h>
...provides an (explicit) declaration for strlen() along with a lot of other
string handling related items.
--
Guy Harrison
Well, take care everyone, and happy holidays to all.