Log in

View Full Version : another compiler bug/oddity?


Rickertsen2
20-02-2006, 03:28
Omit the " at the end of the last include statement in a file and you get a rather strange error in which the compiler quotes a vast region of your code and then tells you there is an error on a seemingly random line.

ie: #include "something.h

If you do this with anything other than that last include statement, error but it is a little less convoluded.

This does not work with include statements that use <> style brackets.

Matt Krass
20-02-2006, 04:30
Omit the " at the end of the last include statement in a file and you get a rather strange error in which the compiler quotes a vast region of your code and then tells you there is an error on a seemingly random line.

ie: #include "something.h

If you do this with anything other than that last include statement, error but it is a little less convoluded.

This does not work with include statements that use <> style brackets.

How is that a bug? It's a programming mistake, you're telling the compiler to include vast amounts of, to the compiler, random data and its confusing the heck out of it. Blaming the compiler for your mistakes isn't a good thing, it could get you in trouble later.

I wouldn't call it an oddity, I'd call it an amusing response to a silly mistake, we all make them so it's not a big deal, just don't attribute them to the compiler, it's not there to clean up after you.

Keith Watson
20-02-2006, 12:43
That is called a syntax error - or typo. The nice thing about editors which use syntax highlighting is that those kind of problems are easy to spot.

Rickertsen2
20-02-2006, 13:40
It just seems to me that it should give you a more sensible error and point you to the line where you made a mistake. Perhaps an "amusing mistake" would be a better term. In any case, i thought it was intereting and unusual enough to post.

MichaelGoldfarb
21-02-2006, 01:20
Well, when the list of problems for the compiler is 24 pages long you are bound to run into weird problems.

Alan Anderson
21-02-2006, 09:18
It just seems to me that it should give you a more sensible error and point you to the line where you made a mistake...
The problem here is that C has very terse syntax. If you make a simple mistake, it's very likely that the result is still "correct" C, and the compiler will happily accept it.

If you misplace a closing brace, A C compiler has no idea where it was really supposed to go. All it knows, for example, is that it encountered an else statement somewhere other than immediately after an if body. The actual error could have been on the previous line, or ten lines up. The compiler can't tell.

Keith Watson
21-02-2006, 12:41
As Alan points out, the compiler cannot know what you intended. If you drop a closing quote, closing multiline comment, etc. how can it know you meant something else? When the compiler fails it is just one of the things you learn to look for.

KenWittlief
21-02-2006, 13:11
Stupid computer keeps doing what I tell it to do

instead of what I want it to do.

Very often if you have a syntax error in your code, all the error messages after the first one are meaningless.

Its like a train jumping the track but still trying to tell you where it is on the track, while it heading down a perpendicular dirt road.

Rickertsen2
21-02-2006, 14:45
Stupid computer keeps doing what I tell it to do

instead of what I want it to do.

Very often if you have a syntax error in your code, all the error messages after the first one are meaningless.

Its like a train jumping the track but still trying to tell you where it is on the track, while it heading down a perpendicular dirt road.
well it should know what i want it to do ;)