Tuesday, January 25, 2011

The autopsy Part1

The ERROR.C program erred! What a shock.
Don’t be alarmed — it was expected. (In fact, you may have seen this type of error before.) Here is a sample of what the cruel message may look like:
error.c: In function `main’:
error.c:6: parse error before “return”

How rude! It’s not that reassuring hand on your shoulder and the kind, avun­cular voice explaining that you boo-booed. Still, what the error message lacks in personality, it makes up for in information.


On the up side, though the error message is cryptic, it’s informative. What­ever your compiler, you should be able to single out the following bits of information:


The source code file that contained the error, error.c
The line that contains the error, Line 6 (though it may not be — youcan’t really trust computers too much)

The type of error, a parse error or syntax error or something similar
The location of the error (before the word return)

It still may not be clear exactly what’s wrong, but you’re given many clues. Most important, you’re given a line number: The error is in Line 6.
Okay, it’s really in Line 5, but the C programming language is flexible, and the compiler doesn’t discover that “something’s missing” until Line 6. (You can cut the compiler some slack here.)

The error type is also important. A parse, or syntax, error means that an item of C language punctuation is missing, and, therefore, two things that aren’t supposed to run together have run together. In this case, a missing semicolon character at the end of Line 5 is to blame.

Welcome to reproduce this passage. Please indicate the source when you reproduce this passage.

No comments:

Post a Comment