Mail Archives: djgpp/2004/07/20/08:00:09
Sterten <sterten AT aol DOT com> wrote:
> >Your program has at least the following errors:
> >
> >#include <stdio.h> is missing
> >#include <stdlib.h> is missing
> I assume, that stdio.h and/or stdlib.h are appended automatically
> (why else would the program run ?) and that including these
> again only blows the whole thing up unnecessarily.
You assume quite incorrectly, and the "why would" question shows
serious lack of understanding about how the C programming language
actually works. For one, thing, appending them wouldn't achieve
anything, they have to be #include'd. Please, get yourself a C
textbook worth having, like K&R2, so you can replace guesswork and
surprises by some hard facts.
> >main is defined without giving a return type
> >main doesn't return a value
> I don't need such a value here.
What you (think you) need is beside the point. It's what the
programming language requires that counts.
Morale: always use gcc options including -Wall, -O and -g, and take
all warnings you get seriously unless you know for absolute certain
that they are benign.
> Once I saw a recommendation somewhere to declare main as int.
Forget "recommendation", make it "requirement". main returns int, and
omitting the return type from a function definition is a completely
outdated feature that has been removed from the language in the latest
standards.
> -g makes the program run correctly, while omitting it doesn't.
If that's indeed that case (and not a side of your 'gc.bat' hackery),
that's a sure sign of a bug. It remains to be seen whether the bug is
in your program, in the tools, or in your hardware, though.
FWIW: I did in the meantime actually compile your code and run it on
an XP box, but it never once crashed in the way you show.
--
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.
- Raw text -