Re: Here's a good one...

From: Keith Thompson (kst-u_at_mib.org)
Date: 06/08/04


Date: Tue, 08 Jun 2004 20:50:04 GMT

Dan.Pop@cern.ch (Dan Pop) writes:
[...]
> Always look at earliest (in terms of line numbers) diagnostic reported
> by the compiler and ignore the rest. Fix it, recompile and follow
> the same strategy if there are still diagnostics.

That's good advice for beginners, and it certainly applies to the OP's
code.

The more advanced version is:

Always look at the earliest diagnostic reported by the compiler.
Anything following a syntax error can probably be ignored; typical C
compilers don't recover well from syntax errors. But semantic errors
(type mismatches, etc.) typically don't cause the same kind of
cascades that syntax errors do.

The very first error message you see is almost certainly meaningful.

Error messages up to and including the first reported syntax error are
likely to be meaningful, but don't spend too much time on them; if you
can't figure out the error, fix the first one (or the first N) and
recompile.

Error messages following a syntax error are likely to be meaningless
cascade errors.

Errors involving typedef names often behave like syntax errors (since
a typedef name is effectively a keyword in most contexts).

Having said all that, fixing each error one at a time and recompiling
for each fix isn't an unreasonable approach. (I usually try to fix as
many errors as I can, because I typically build large software
packages with multiple levels of auto-configuration and Makefiles;
re-running a single compilation isn't always practical, and the entire
build can take hours. A novice isn't likely to be in that situation.)

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
San Diego Supercomputer Center             <*>  <http://users.sdsc.edu/~kst>
We must do something.  This is something.  Therefore, we must do this.


Relevant Pages

  • Re: The Decline of C/C++, the rise of X
    ... >> Jim points out later, and poorer error messages on a syntax error, as ... > clearly identify the position of an error is a feature of a compiler ...
    (comp.programming)
  • Re: The Decline of C/C++, the rise of X
    ... >> Jim points out later, and poorer error messages on a syntax error, as ... > clearly identify the position of an error is a feature of a compiler ...
    (comp.programming)
  • Re: The Decline of C/C++, the rise of X
    ... >> Jim points out later, and poorer error messages on a syntax error, as ... > clearly identify the position of an error is a feature of a compiler ...
    (comp.programming)
  • Re: The Decline of C/C++, the rise of X
    ... >> Jim points out later, and poorer error messages on a syntax error, as ... > clearly identify the position of an error is a feature of a compiler ...
    (comp.programming)
  • Re: get_item_price - Dont LIKE FUNCTIONS
    ... > What am I missing, I know it's right in front of me<?. ... Learn to read the error messages the compiler is telling you. ... I would not pay much attention to subsequent error message until you fix that ...
    (comp.lang.cpp)