From 1007664114399328310
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,314ebdf2ff957e27
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 2003-04-11 15:54:03 PST
Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!kibo.news.demon.net!mutlu.news.demon.net!demon!mail2news.demon.co.uk!devnull
From: jdennett@acm.org (James Dennett)
Newsgroups: comp.std.c++
Subject: Re: Why int main()?
Date: Fri, 11 Apr 2003 22:54:02 +0000 (UTC)
Organization: EarthLink Inc. -- http://www.EarthLink.net
Lines: 36
Approved: fjh@cs.mu.oz.au (Fergus Henderson , moderator of comp.std.c++)
Message-ID: <DaGla.19630$ey1.1684332@newsread1.prod.itd.earthlink.net>
References: <Qbvla.955$5Z2.28625@newsfep1-win.server.ntli.net> <RkkxdPDmqwl+Ewp6@robinton.demon.co.uk>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: mail2news.demon.co.uk 1050101642 345 10.0.0.1 (11 Apr 2003 22:54:02 GMT)
X-Complaints-To: abuse@demon.net
NNTP-Posting-Date: Fri, 11 Apr 2003 22:54:02 +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 1947PE-00005P-00
	for mail2news@news.news.demon.net; Fri, 11 Apr 2003 22:54:01 +0000
X-Received: from localhost (localhost [[UNIX: localhost]]) by mulga.cs.mu.OZ.AU
	id IAA04962; Sat, 12 Apr 2003 08:53:57 +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-User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.3) Gecko/20030312
X-Accept-Language: en-us, en
X-Newsgroups: comp.std.c++
X-NNTP-Posting-Date: Fri, 11 Apr 2003 14:09:55 PDT
X-Spam-Status: No, hits=-10.1 required=5.0
	tests=INVALID_MSGID,IN_REP_TO,NOSPAM_INC,QUOTED_EMAIL_TEXT,
	      REFERENCES,SPAM_PHRASE_00_01,USER_AGENT,
	      USER_AGENT_MOZILLA_UA,X_ACCEPT_LANG
	version=2.41
Xref: archiver1.google.com comp.std.c++:18742

Francis Glassborow wrote:
> In article <Qbvla.955$5Z2.28625@newsfep1-win.server.ntli.net>, Huw Ford 
> <Huw@Tesco.net> writes
> 
>> A lot of compilers will accept "void main()" so why must main return 
>> an int?
> 
> 
> Because Standards are about portability. It is easy for a system to 
> ignore a return value when it does not need one, it is much harder to 
> create one where it is needed and none has been provided.

And yet there's a wart in C++ because main is the _only_
function returning int where we do not have to providfe a
return value when the function exits, as a default value
is indeed provided.

Standardising void main() as being the same as int main()
but not allowing an expression after return, and acting
as if it was int main() returning 0, would be quite
possible technically.  It would gain nothing except to
silence the endless discussion of why void main is not
legal.

It's trivial to turn a program with void main into a legal
one: s/void main/int main/.  A saving of one character,
and the code becomes standard C++ (in that aspect at least).

-- James.

---
[ 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                       ]



