Send Close Add comments: (status displays here)
Got it!  This site "robinsnyder.com" uses cookies. You consent to this by clicking on "Got it!" or by continuing to use this website.  Note: This appears on each machine/browser from which this site is accessed.
C: Compiler-detected errors
by RS  admin@robinsnyder.com : 1024 x 640


1. Errors
Obzerved and desired behaviorAn error and a change are both defined as a difference between the observed behavior and the expected or desired behavior.

One should be able to see that the difference between an "error" and a "change" is a matter of perspective.

To identify an error requires a specification and one should not use the operational code as a specification.

Information sign More: Errors and changes

2. Jumping out of a plane
Airborne wings10 days training (airborne school) for getting ready to jump out of a plane (with a parachute): In programming, one spends some time learning how to do things and a lot of time determining what to do when things do not work as expected.

3. Good judgment
Good judgment is the result of experience and experience the result of bad judgment.
Mark Twain (Author and Humorist, alias Samuel Clemens)

Information sign More: Mark Twain

4. Programming
Dijkstra provides a pragmatic description of the programming process.
I think that the behavior of the efficient programmer can be described as trying to take the easiest decision first, that is, the decision that requires the minimum amount of investigation (trial and error, iterative mutual adjustment etc.) for the maximum justification of the hope that he will not regret it. Edsger Dijkstra (computer scientist)

Dahl, O., Dijkstra, E., & Hoare, C. (1972). Structured programming. New York: Academic Press., p. 72.

That is, one may be wrong.

Information sign More: Edsger Dijkstra
How does a compiler detect errors? In simple terms, a compiler takes one character at a time from the source file, following syntax and grammar rules, until an error is detected.

5. Empty program
The following program is an empty program that does nothing (i.e., no input or output).

Here is the C code [#1]


6. Hello, World
The following program outputs the text "Hello, World" to the standard output.

Here is the C code [#2]

Here is the output of the C code.


7. Error messages
Error messages should be called "detected error messages" since the compiler detected that something is not right, but cannot know exactly what is not right.

Whenever multiple error messages are detected, the first error is the important one. The others are usually spurious - caused by the first error.

In each detected error message, the source file is listed first. Then the line and (sometimes) column at which the error was detected, then the message. The message is sometimes helpful.

8. Warnings
A "Warning" from the compiler should be treated as an error. The first thing the compiler finds that it does not like should be considered an error.

9. Missing include
What happens if the include directive is missing?

Here is the C code [#3]

Here is the error text of the C code.

Without the include directive for stdio.h, the compiler cannot find a definition for printf.

10. Missing semicolon
What happens if the ending semicolon ";" is missing?

Here is the C code [#4]

Here is the error text of the C code.

One often has to backtrack to the end of the previous line (or whitespace) to find the likely location of the actual error.

11. Missing double quote
What happens if the ending double quote character is missing?

Here is the C code [#5]

Here is the error text of the C code.


12. Missing double quote
The following happens if single quotes are used instead of double quotes in the output statement.

Here is the C code [#6]

Here is the error text of the C code.

C uses single quotes to delimit single characters.

C uses double quotes to delimit sequences of zero or more characters - a character string.

13. End of page

by RS  admin@robinsnyder.com : 1024 x 640