Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

gcc Warning Messages

9 views
Skip to first unread message

News

unread,
Dec 12, 2003, 10:33:19 PM12/12/03
to
I'm new to c and gcc. I was wondering if anyone can point me to a web page
or book that has a list of the warning messages and their meanings.

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.


Artie Gold

unread,
Dec 12, 2003, 11:02:07 PM12/12/03
to

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.

News

unread,
Dec 13, 2003, 12:56:58 AM12/13/03
to
Thank you for the input. But the reason I posted this was to find out if
there is a website or publication that has a listing of the compiler
warnings and their meaning. Also, since I'm new to c and gcc, are the
warnings the same for all compilers, or are the warnings different for each
compiler.

Guy Harrison

unread,
Dec 13, 2003, 1:14:08 PM12/13/03
to
News wrote:

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

Jakle

unread,
Dec 13, 2003, 4:01:05 PM12/13/03
to
Thank you guys, and I apoligize for posting this in the wrong news group. I
thought that it was a gcc thing. I will be sure to post to c.l.c from now
on. It was very nice and helpful of you to reply to someone in the early
stages of learning and discovery (I hate the term "noob" ;-) ).

Well, take care everyone, and happy holidays to all.


0 new messages