delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2004/07/20/08:00:09

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
From: Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: strange error
Date: 20 Jul 2004 11:53:15 GMT
Lines: 48
Message-ID: <2m4fdbFinvsjU1@uni-berlin.de>
References: <2m4apdFht547U1 AT uni-berlin DOT de> <20040720073802 DOT 22465 DOT 00000145 AT mb-m11 DOT aol DOT com>
X-Trace: news.uni-berlin.de w+OfDDVEpzCObcTtPr8X0AwSxoYnuY2BZ4a+hikvUgfbFfCaXzyj/whfl4
X-Orig-Path: not-for-mail
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019