delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/05/10/19:47:15

From: Ross Litscher <Litscher DOT 1 AT osu DOT edu>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: compile warning
Date: Sat, 10 May 1997 16:57:42 -0400
Organization: The Ohio State University
Lines: 70
Message-ID: <3374E145.7177@osu.edu>
References: <97May10.184721gmt+0100 DOT 16645 AT internet01 DOT amc DOT de> <3374B89C DOT 52FC7701 AT alcyone DOT com>
Reply-To: Litscher DOT 1 AT osu DOT edu
NNTP-Posting-Host: s-100-225.resnet.ohio-state.edu
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Erik Max Francis wrote:
> 
> Chris Croughton wrote:
> 
> > > first, this is pure and simple C. in any case, void is not a valid
> > > return type for main.
> >
> > Incorrect.  Void is a perfectly good return type for main.
> 
> Wrong.  ANSI C standard, section 5.1.2.2.1.
> 
> > > main has to return an int.
> >
> > No it doesn't.  It only needs to generate any specific exit value
> > if you will be using the result to test the state of the program
> > afterwards (like in make or with the batch ERRORLEVEL).
> 
> No; the standard dictates that main must conform to one of the following
> two prototypes:
> 
>     int main(void);
>     int main(int argc, char *argv[]);
> 
> > And even
> > then it's perfectly valid to use exit(n) rather than return.
> 
> ANSI C 7.10.4.3.  Control is returned to the host environment, and
> successful termination or unsuccessful termination is "returned."  This
> means that from the point of view of a program-executing environment,
> calling exit makes the program look like it returned from main.
> 
> > It may be considered, in some places, good /style/ to declare main
> > as int, but that's a long way from it being an absolute.
> 
> No.  It is an ANSI violation to have main return anything other than int,
> even if your host environment doesn't do anything valuable with the return
> values.
> 
> > Even with -Wall -ansi -pedantic I can't get gcc to complain about
> > void main...
> 
> So?  Just because a compiler doesn't complain about something doesn't that
> something ANSI C compliant.
> --
>        Erik Max Francis, &tSftDotIotE / email / max AT alcyone DOT com
>                      Alcyone Systems /   web / http://www.alcyone.com/max/
> San Jose, California, United States /  icbm / 37 20 07 N  121 53 38 W
>                                    \
>                       "The future / is right there."
>                                  / Bill Moyers

Sorry, I didn't mean for my sloppy coding, and using mostly code I found
on the net, to start a debate. :/ 

so, the stdio.h was the problem with the rand(). That part of the code
is what I got off a tutorial, so I assumed it to be correct. as for my
code for slowing down the program, i should do something like delay(250)
or something... and for the 'void main(void) y'all confused me a bit.
should i do something like:

int main()	
{
...
return 0;
}

remember, newbie here, just trying to clear things up in my mind. I'd
like to do things correctly.... someday. please be patient. 

Ross

- Raw text -


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