From -7759657128315611519
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,314ebdf2ff957e27
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 2003-04-11 11:49:05 PST
Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!news-hog.berkeley.edu!ucberkeley!news2.epix.net!newspump.monmouth.com!newspeer.monmouth.com!newsfeed.icl.net!newsfeed.fjserv.net!kibo.news.demon.net!mutlu.news.demon.net!demon!mail2news.demon.co.uk!devnull
From: do-not-spam-ben.hutchings@businesswebsoftware.com (Ben Hutchings)
Newsgroups: comp.std.c++
Subject: Re: Why int main()?
Date: Fri, 11 Apr 2003 18:49:04 +0000 (UTC)
Lines: 28
Approved: fjh@cs.mu.oz.au (Fergus Henderson , moderator of comp.std.c++)
Message-ID: <slrnb9d7fn.1m0.do-not-spam-ben.hutchings@tin.bwsint.com>
References: <Qbvla.955$5Z2.28625@newsfep1-win.server.ntli.net>
X-Trace: mail2news.demon.co.uk 1050086944 29325 10.0.0.1 (11 Apr 2003 18:49:04 GMT)
X-Complaints-To: abuse@demon.net
NNTP-Posting-Date: Fri, 11 Apr 2003 18:49:04 +0000 (UTC)
X-Received: from mulga.cs.mu.oz.au ([128.250.1.22])
	by news.demon.co.uk with esmtp (Exim 4.12)
	id 1943aB-0007ch-00
	for mail2news@news.news.demon.net; Fri, 11 Apr 2003 18:49:03 +0000
X-Received: by mulga.cs.mu.OZ.AU
	id EAA21323; Sat, 12 Apr 2003 04:49:00 +1000 (EST)
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
X-Path: comp-std-cpp-robomod!not-for-mail
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
X-Delivered-To: std-c++@ucar.edu
X-Newsgroups: comp.std.c++
X-Reply-To: Ben Hutchings <ben.hutchings@businesswebsoftware.com>
X-Orig-NNTP-Posting-Host: gold.businesswebsoftware.com (195.74.108.82)
X-Orig-X-Trace: fu-berlin.de 1050058232 12101458 195.74.108.82 (16 [70929])
X-User-Agent: slrn/0.9.7.4 (Win32)
X-Spam-Status: No, hits=-6.7 required=5.0
	tests=QUOTED_EMAIL_TEXT,REFERENCES,SPAM_PHRASE_00_01,USER_AGENT
	version=2.41
Xref: archiver1.google.com comp.std.c++:18730

In article <Qbvla.955$5Z2.28625@newsfep1-win.server.ntli.net>,
"Huw Ford" wrote:
> Why was main defined as returning int?
> A lot of my work has been with embedded devices where the program never
> returns from main.

Then you're probably working with freestanding implementations, where the
entry point is implementation-defined, so it might not be called main and
might not be expected to return int.  (Section 3.6.1 paragraph 1.)

<snip>
> A lot of compilers will accept "void main()" so why must main return an
> int?

In most environments, a terminating process returns some kind of status
value indicating at least success or failure.  Logically main() should
return a value that becomes this status value.  At least some C compilers
treat main() just like any other function, and their startup code expects
it to return an int.  This could have been changed in C++, since C++
compilers do have to treat main() specially in some respects, but why
change it when a return type of int is logically correct?

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]



