473,396 Members | 1,847 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Compiler Warnings

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
different for each compiler? I have looked all over the gcc web site, but I
can't find anything that explains what the warnings are.

If someone could take the time to help me out and direct me to some info
about this, I'd appriciate it.

Thanks

Nov 14 '05 #1
20 2677
"News" <ja****@hotmail.com> writes:
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.
Unlike some compilers' warnings, GCC's are meant to be
self-explanatory. There isn't a place, that I know of, which has
the explanations you are looking for.

If there is a specific warning, or a few, that you would like
explained, c.l.c is a good place to ask. Note that c.l.c is
generally not the right place to ask questions about specific
compilers, but warnings tend to be more about C than about
compilers.
Are the warnings the same no matter what compiler you use, or are they
different for each compiler? I have looked all over the gcc web site, but I
can't find anything that explains what the warnings are.


Every compiler has different warnings.
--
int main(void){char p[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuv wxyz.\
\n",*q="kl BIcNBFr.NKEzjwCIxNJC";int i=sizeof p/2;char *strchr();int putchar(\
);while(*q){i+=strchr(p,*q++)-p;if(i>=(int)sizeof p)i-=sizeof p-1;putchar(p[i]\
);}return 0;}
Nov 14 '05 #2
Ben Pfaff wrote:


Every compiler has different warnings.


This is true in two different senses: first, the actual text that is
emitted for a given condition may be different. Second, the choice
whether or not to emit a warning for some condition may be different.

In other words, code that causes one compiler to generate a warning may
cause a different compiler to generate a different warning or no warning
at all.

The standard requires certain conditions to generate a diagnostic, so
some conditions must evoke some form of warning from a
standard-compliant compiler.

-Kevin
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.
Nov 14 '05 #3
Ben Pfaff wrote:
"News" <ja****@hotmail.com> writes:
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.

Unlike some compilers' warnings, GCC's are meant to be
self-explanatory. There isn't a place, that I know of, which has
the explanations you are looking for.


IBM, at least for the mainframes, and even for other systems, has a
tradition of supplying manuals describing all the messages a given
program could generate. Usually it will describe in more detail than
the printed message the cause, and suggested action to take.

There may be other companies that have a similar system, but it is
not so common. Though I believe that early microsoft compilers
may have done it.

-- glen

Nov 14 '05 #4
glen herrmannsfeldt wrote:

<snip>
IBM, at least for the mainframes, and even for other systems, has a
tradition of supplying manuals describing all the messages a given
program could generate. Usually it will describe in more detail than
the printed message the cause, and suggested action to take.


I have fond (but admittedly vague) memories of these messages:

I40008291 An error has occurred.

Suggested action: Correct the error and re-submit the job.

;-)

--
Richard Heathfield : bi****@eton.powernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
Nov 14 '05 #5
Thank you guys for the info. I remember when I was a kid my father would
have a pocket size book full of warnings he could look at if anything came
up. Like they say, I just have to keep coding and making mistakes, then I
will get less warnings, and also get familiar with what they are. Thanks
again
Nov 14 '05 #6
Jakle wrote:
Thank you guys for the info. I remember when I was a kid my father would
have a pocket size book full of warnings he could look at if anything came
up. Like they say, I just have to keep coding and making mistakes, then I
will get less warnings, and also get familiar with what they are. Thanks
again

Why not train yourself, by making deliberate mistakes and watching what the
compiler does? For example, try leaving a semicolon off a declaration. Or
try using an undefined variable. Or try missing out a necessary header.

--
Richard Heathfield : bi****@eton.powernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
Nov 14 '05 #7
Richard Heathfield wrote:

(snip)
Why not train yourself, by making deliberate mistakes and watching what the
compiler does? For example, try leaving a semicolon off a declaration. Or
try using an undefined variable. Or try missing out a necessary header.


I remember a compiler I used to use (not a C compiler) that would
attempt to correct errors. (In the internal representation of the
source program only.) So it had messages like:

Semicolon missing, one inserted in line 123.

In the days of batch programming, it was useful to get as much
out of a compiler run as possible. This would allow the
compiler to get farther through the program, and find more
errors, before giving up.

I don't remember if it could detect unclosed comments, an easy
mistake to make in languages with multiline comments.

-- glen

Nov 14 '05 #8
Richard Heathfield wrote:
glen herrmannsfeldt wrote:

<snip>
IBM, at least for the mainframes, and even for other systems, has a
tradition of supplying manuals describing all the messages a given
program could generate. Usually it will describe in more detail than
the printed message the cause, and suggested action to take.

I have fond (but admittedly vague) memories of these messages:

I40008291 An error has occurred.

Suggested action: Correct the error and re-submit the job.


Yes, some were like that. It does remind me, though, of the time
my program died with a Machine Check error on a system that charged
real money for CPU time, lines printed, etc. It took some
convincing to get credit for a problem that was not my fault.

Machine Check is a hardware error in the processor, that the
processor can detect. Memory parity might be one, though they
usually checked more than that.

-- glen

Nov 14 '05 #9
"News" <ja****@hotmail.com> wrote in message
news:BR******************@news1.news.adelphia.net. ..
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.
The content and meanings of compiler warning (and error) messages
are unique to each compiler.

Are the warnings the same no matter what compiler you use,

No.
or are they
different for each compiler?
Yes.
I have looked all over the gcc web site, but I
can't find anything that explains what the warnings are.
I suggest you read more closely :-). I'm sure the gcc manual
has these descriptions.

Also, if you have some code that's producing a warning you don't
understand, you can post it here and others will probably be able
to spot the trouble. But only post enough code to demonstrate the
problem.

If someone could take the time to help me out and direct me to some info
about this, I'd appriciate it.


Any questions about gcc, I'd direct to the gnu web site and/or newsgroups.

-Mike
Nov 14 '05 #10
Jakle <ja****@hotmail.com> spoke thus:
Thank you guys for the info. I remember when I was a kid my father would
(etc)


In the future, please include the relevant text of the person you are
replying to and make your own comments below it. It's considered
good manners here.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Nov 14 '05 #11
Richard Heathfield <do******@address.co.uk.invalid> spoke thus:
I40008291 An error has occurred.
Suggested action: Correct the error and re-submit the job.


About as helpful as "No ROM BASIC, system halted"...

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Nov 14 '05 #12
Kevin Goodsell <us*********************@neverbox.com> spoke thus:
The standard requires certain conditions to generate a diagnostic, so
some conditions must evoke some form of warning from a
standard-compliant compiler.


When the appropriate compiler options are enabled, of course, i.e.
-ansi for gcc.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Nov 14 '05 #13
In <O3LCb.40792$8y1.172456@attbi_s52> glen herrmannsfeldt <ga*@ugcs.caltech.edu> writes:
Richard Heathfield wrote:

(snip)
Why not train yourself, by making deliberate mistakes and watching what the
compiler does? For example, try leaving a semicolon off a declaration. Or
try using an undefined variable. Or try missing out a necessary header.


I remember a compiler I used to use (not a C compiler) that would
attempt to correct errors. (In the internal representation of the
source program only.) So it had messages like:

Semicolon missing, one inserted in line 123.


VAX C used to do that. The warning codename was SEMICOLONADDED.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #14
In <as****************@newsread1.news.pas.earthlink.n et> Kevin Goodsell <us*********************@neverbox.com> writes:
The standard requires certain conditions to generate a diagnostic, so
some conditions must evoke some form of warning from a
standard-compliant compiler.


Nope, they must evoke some form of diagnostic. It's up to the implementor
to decide whether each specific condition is handled as a warning or as
an error.

IMO, users would be better served by compilers that handled each and
every required diagnostic as an error, reserving warnings for dubious
program constructs that don't require a diagnostic.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #15
In article <br**********@chessie.cirr.com>,
Christopher Benson-Manica <at***@nospam.cyberspace.org> wrote:
Kevin Goodsell <us*********************@neverbox.com> spoke thus:
The standard requires certain conditions to generate a diagnostic, so
some conditions must evoke some form of warning from a
standard-compliant compiler.
When the appropriate compiler options are enabled, of course, i.e.
-ansi for gcc.


Without the appropriate options, it's not a standard-compliant compiler.

F'rexample, "gcc" without any options specified is a Rather Different
compiler than "gcc -W -Wall -ansi -pedantic -O".
dave

--
Dave Vandervies dj******@csclub.uwaterloo.ca your a morron.

Beautiful. Classic sig block material.
--Richard Heathfield roasts a troll in comp.lang.c
Nov 14 '05 #16
glen herrmannsfeldt <ga*@ugcs.caltech.edu> writes:
[...]
I remember a compiler I used to use (not a C compiler) that would
attempt to correct errors. (In the internal representation of the
source program only.) So it had messages like:

Semicolon missing, one inserted in line 123.


The (non-C) compiler I used to work on did something similar. It
internally corrected any syntax errors until it managed to build a
syntactically correct representation of the input program. (This was
done only for error recovery; syntax errors, even correctable ones,
were considered fatal.)

If you fed it garbage (e.g., a file of English text), it would usually
reduce it to nothing, recognizing any keywords along the way.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://www.sdsc.edu/~kst>
Schroedinger does Shakespeare: "To be *and* not to be"
(Note new e-mail address)
Nov 14 '05 #17
In <br**********@chessie.cirr.com> Christopher Benson-Manica <at***@nospam.cyberspace.org> writes:
Kevin Goodsell <us*********************@neverbox.com> spoke thus:
The standard requires certain conditions to generate a diagnostic, so
some conditions must evoke some form of warning from a
standard-compliant compiler.


When the appropriate compiler options are enabled, of course, i.e.
-ansi for gcc.


It's actually -pedantic that enables most of the required diagnostics that
gcc doesn't generate by default. gcc -ansi is a conforming translator,
except for the diagnostics issue. For "full" conformance, you need
-ansi -pedantic. I used the double quotes because even with these
options there are floating point issues left, some of which can be cured
by -ffloat-store (at the expense of slowing down the generated code).

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #18
In message <br**********@sunnews.cern.ch>
Da*****@cern.ch (Dan Pop) wrote:
IMO, users would be better served by compilers that handled each and
every required diagnostic as an error, reserving warnings for dubious
program constructs that don't require a diagnostic.


I agree with Dan totally on this point (for once), and that's what the
compiler I maintain tries to ensure. Every required diagnostic is an error or
serious error. Warnings are only advisory. Undefined behaviour may lead to
either or neither.

This means that the "implicit int" diagnostic is an error in C99 mode too. It
used to be a warning.

I don't know how I'd have coped learning C if I hadn't originally learnt on
such a compiler.

--
Kevin Bracey, Principal Software Engineer
Tematic Ltd Tel: +44 (0) 1223 503464
182-190 Newmarket Road Fax: +44 (0) 1223 503458
Cambridge, CB5 8HE, United Kingdom WWW: http://www.tematic.com/
Nov 14 '05 #19
In message <ln************@nuthaus.mib.org>
Keith Thompson <ks***@mib.org> wrote:
glen herrmannsfeldt <ga*@ugcs.caltech.edu> writes:
[...]
I remember a compiler I used to use (not a C compiler) that would
attempt to correct errors. (In the internal representation of the
source program only.) So it had messages like:

Semicolon missing, one inserted in line 123.


The (non-C) compiler I used to work on did something similar. It
internally corrected any syntax errors until it managed to build a
syntactically correct representation of the input program.


The C compiler I maintain does pretty much exactly this, and will correct
most simple errors. It does bail out and skip until a terminator in the
event of a serious parse failure though.

For example, feeding it your last paragraph gives:

"c.x", line 1: Error: expected ')' or ',' - inserted ')' before '-'
"c.x", line 1: Error: function prototype formal 'non' needs type or class - 'int' assumed
"c.x", line 1: Error: declaration lacks type (assuming 'int'): 'The'
"c.x", line 1: Error: expected ';' or ',' - inserted ';' before '-'
"c.x", line 1: Serious error: Expecting <declarator> or <type> but found '-'
"c.x", line 4: Error: expected ';' or ',' - inserted ';' before <eof>

So it corrected it to

The (non);-C) ... program.;

And then interpreted it as

int The(int non);

--
Kevin Bracey, Principal Software Engineer
Tematic Ltd Tel: +44 (0) 1223 503464
182-190 Newmarket Road Fax: +44 (0) 1223 503458
Cambridge, CB5 8HE, United Kingdom WWW: http://www.tematic.com/
Nov 14 '05 #20
On Sun, 14 Dec 2003 18:14:21 GMT, "Mike Wahler"
<mk******@mkwahler.net> wrote:
<snip>
The content and meanings of compiler warning (and error) messages
are unique to each compiler.
Yes.
<snip>
I have looked all over the gcc web site, but I
can't find anything that explains what the warnings are.


I suggest you read more closely :-). I'm sure the gcc manual
has these descriptions.

No, the GCC documentation does not contain descriptions of the
diagnostic messages as such. Some diagnostics are controlled by flags
(-W*) because they are (though) less likely to really be problems, and
the descriptions of these flags do explain to some extent the meaning
of the related diagnostics, but not their exact wording.

I don't recall anyone who made a practice of actually releasing
documentation of "error" or diagnostic or similar messages but IBM
(already mentioned) and DEC.
Also, if you have some code that's producing a warning you don't
understand, you can post it here and others will probably be able
to spot the trouble. But only post enough code to demonstrate the
problem.

Yes, except the usual advice is to post the smallest "possible" (or at
least the smallest you can find) *complete* program. Posting just
excerpts of code often omits information that turns out to be vital.

- David.Thompson1 at worldnet.att.net
Nov 14 '05 #21

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: dis | last post by:
I've been going through my code and clearing away some of the compiler warnings that i'm generating and i've come across areas where i cast pointers to integer values. The Visual Studio compiler...
8
by: Charlie Zender | last post by:
Hi, First, this may be a GCC or Linux-specific problem, I'm not sure. I am unable to compile a large body of code with extremely pedantic compile time checks activate, so that warnings cause...
43
by: Anitha | last post by:
Hi I observed something while coding the other day: if I declare a character array as char s, and try to use it as any other character array..it works perfectly fine most of the times. It...
29
by: Daniel Rudy | last post by:
Hello, Consider the following code fragment: fileptr = fopen(param->filename, "r"); if (fileptr == NULL) { error("digest.c: digest_file: Open File ", errno); return(-2); }
2
by: Samuel | last post by:
Imagine you have the following code: try { ... } catch (ThreadAbortException eThread) { if (WorkStopped != null) WorkStopped(this, EventArgs.Empty) }
5
by: rawCoder | last post by:
Hi All, In Visual Basic .NET , your function definition might requirre you to return a value but (accidently/intentionally) you dont put any 'return value' in the function. In this case VB...
11
by: Charles Sullivan | last post by:
I have a number of functions, e.g.: int funct1( int arg1, int arg2, int arg3 ); int funct2( int arg1, int arg2, int arg3 ); int funct3( int arg1, int arg2, int arg3 ); that are called via...
3
by: gil | last post by:
Hi, I'm trying to find the best way to work with compiler warnings. I'd like to remove *all* warnings from the code, and playing around with the warning level, I've noticed that compiling with...
3
by: Peted | last post by:
Hi Im using vs2008 c# 3.0 and am going through some other person(s) code to clean up compiler warnings that are bieng produced. I have this code (at bottom) where a delegate/event is...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.