Re: Why C/C++ errors are SO obscure/devious??
- From: "Emmanuel Delahaye" <emdel@xxxxxxxxxxxxxx>
- Date: Tue, 30 Aug 2005 20:53:22 +0200
Massimo Soricetti wrote on 30/08/05 :
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.
Yes, the very common "';' missing "error is undetected. This is due to the C-syntax.
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.
An include file. Yes.
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)
Note that the error messages are a part of the implementation and not of the language itself. The language only requires 'diagnostics'.
Some compilers have very good messages (Intel, for example) but AFAIK, there are not free (free beer).
Note also that you should only consider the first error. Setting the compiler to stop at the first error certainely is a gain(?) of time.
Why can't a compiler give more accurate informations about errors? Shouldn't this save time, stress and money?
Switch to Pascal !
Another example: have you ever met the error line "Multiple definitions of..."?
Yes. It's a common design error. (object definitions in a header, stuffs like that...)
For example, why can't a compiler start a negotiation "on the fly" like this:
ERROR: Multiple definitions of <variable|function|method> X. X defined: 1) <here1> as variable <line of code definition...> 2) <here2> as variable <line of code definition...> 3) <here3> as function <line of code definition...> Choose which definition is the right one:
No. A design error should be fixed.
This is "interactive compiling", isn't it?
No. It's a batch process. However, some IDE's have a 'stop' button.
Why not? Why the compiler can't simply ask us, in doubt, and on response modify sources accordingly on its own, in this case and in other similar? This would ease the programming effort a lot.
With a good IDE (Borland C++, VC++6, Dev-C++, Kdevelop), the process is not far from it. You generally have an error list, you just click on the error, and it automagically points to the error line into the source file.
AFAIK, ol'good 'vi' and 'emacs' can do that from the earliest times...
-- Emmanuel The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html The C-library: http://www.dinkumware.com/refxc.html
"There are 10 types of people in the world today; those that understand binary, and those that dont."
.
- References:
- Why C/C++ errors are SO obscure/devious??
- From: Massimo Soricetti
- Why C/C++ errors are SO obscure/devious??
- Prev by Date: Re: low-level question
- Next by Date: Re: object code from which compiler
- Previous by thread: Re: Why C/C++ errors are SO obscure/devious??
- Next by thread: Re: Why C/C++ errors are SO obscure/devious??
- Index(es):