Re: Why C/C++ errors are SO obscure/devious??



In article <IM%Qe.120733$fm.7885188@xxxxxxxxxxxx>, Massimo Soricetti
<massimo_main@xxxxxxxxxxx> writes
>Hello,
>
>I'm not a C newbie, but I'm teaching C programming (well... FIRST
>programming and then C) to other guys these days and it's driving me to
>some reflexions on the language.
>
>It's not uncommon to forget a } writing code, and at compiling time get
>an error 18956778 lines after the mistake, in an otherwise absolutely
>correct piece of code. Or, sometimes in my journeys I got errors
>reported in a file, checked and found it correct, and discovered it was
>caused by an error in another file. And in general, I noted that many,
>if not all, error messages from the compiler are VERY short and cryptic,
>while a couple of words more could sometimes help a lot in understanding
>what's wrong and where, for newbies. Well, not only for them... maybe a
>compiler switch --NOOB_ERR_MSGS could be very handy for some people :o)
>
>Why can't a compiler give more accurate informations about errors?

Because a C compiler is a translator. Not an error checker. It tries to
make the most complex statement it can from the tokens.

For error checking use Lint. that is whit it is designed for.

>Shouldn't this save time, stress and money?

Lint will. Why aren't you using it? If you are teaching C you should be
using Lint as part of the system.


>Another example: have you ever met the error line "Multiple definitions
>of..."?
>
>For example, why can't a compiler start a negotiation "on the fly" like
>this:

You write the compiler to do it then?

>This is "interactive compiling", isn't it? Why not? Why the compiler
>can't simply ask us, in doubt, and on response modify sources
>accordingly on its own,

CERTAINLY NOT....

> in this case and in other similar? This would
>ease the programming effort a lot.
>
>What are your opinions on this matter?


You should it right not look for an easy way of apparently auto-
correcting errors.

1 more care when programming.
2 Use lint
3 run lint OFTEN (or even use the compiler often) every few lines. that
way you catch errors when they appear.
4 short functions that can be unit tested individually (with stubs if
required

5The above is basic programming. If you don't know that should you be
teaching?


--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills Staffs England /\/\/\/\/
/\/\/ chris@xxxxxxxxxxxx www.phaedsys.org \/\/\
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/



.



Relevant Pages

  • Re: Buying board for teaching PICs
    ... >I'm teaching someone embedded design. ... >Support for C programming ... There is a good free compiler, ... For debugging JTAG or Debugwire is required. ...
    (comp.arch.embedded)
  • Re: Why C/C++ errors are SO obscure/devious??
    ... >>>I'm not a C newbie, but I'm teaching C programming (well... ... >>>if not all, error messages from the compiler are VERY short and cryptic, ... >> For error checking use Lint. ...
    (comp.lang.c)
  • Re: Why C/C++ errors are SO obscure/devious??
    ... >>I'm not a C newbie, but I'm teaching C programming (well... ... >>if not all, error messages from the compiler are VERY short and cryptic, ... The decision to make lint a separate tool from the compiler is an old ...
    (comp.lang.c)
  • Re: [EGN] Numerical Accuracy
    ... The advice worked because in fact the Microsoft compiler had a bug. ... The capabilities of the optimizer are not so ... The language standard itself says ... of "programming" as a nonprofession. ...
    (comp.programming)
  • Re: Brian Kernighan, maybe Im not worthy, maybe Im scum
    ... and just hone in on the stuff related to programming and this newsroup] ... moron that was taken from optimization which does hoist when to do so ... compiler design and optimization, including my 1976 text in graduate ... loop in a language in which the designers messed up, ...
    (comp.programming)