Re: Why C/C++ errors are SO obscure/devious??
- From: jacob navia <jacob@xxxxxxxxxxxxxxxx>
- Date: Wed, 31 Aug 2005 00:08:49 +0200
Massimo Soricetti wrote:
Hello,
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.
This can be efficiently handled in the IDE (Integrated development Environment).
In the IDE of lcc-win32, when you save a file, the IDE will check for 1) mismatched braces, parentheses and brackets 2) Syntax errors 3) Mismtached #if/#ifdef
In the case of mismatched braces it will keep stack of positions of opening braces and in most cases it will be able to tell you where the opening brace is that it is mismatched.
I do not think that this is the job of the compiler itself but it is the job of the environment where you build your programs.
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.
This is true, and the lcc-win32 system tries to give as detailed and clear error messages as possible? For instance it avoids: lvalue required
and it says
the left hand side can't be assigned to, what is (in my opinion) much clearer.
Contrary to many people around, I find that your messages has a very valid reason, and I think it is useful.
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? Shouldn't this save time, stress and money?
In many cases this is very hard. Error analysis is quite difficult, specially when a missing right brace can completely change the meaning of the program...
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:
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:
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, in this case and in other similar? This would ease the programming effort a lot.
I think this is out of the question. It is not possible to leave a blatant error in the source code like that, and compiling anyway.
Suppose you said: I want the option 3.
Then you compile, ship the program, and several months later you wonder My program is crashing but I forgot which option I typed in when the compiler asked damm. Which one should I debug now?????
jacob
lcc-win32: a compiler system for windows http://www.cs.virginia.edu/~lcc-win32 .
- Follow-Ups:
- Re: Why C/C++ errors are SO obscure/devious??
- From: Gordon Burditt
- Re: Why C/C++ errors are SO obscure/devious??
- References:
- Why C/C++ errors are SO obscure/devious??
- From: Massimo Soricetti
- Why C/C++ errors are SO obscure/devious??
- Prev by Date: Re: Function pointer prototype interpretation
- Next by Date: Re: while (1) vs. for ( ;; )
- 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):
Relevant Pages
|