From mboxrd@z Thu Jan 1 00:00:00 1970 To: 9fans@cse.psu.edu Subject: Re: [9fans] the declaration of main() From: forsyth@vitanuova.com MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Message-Id: <20010423110853.3397219A61@mail.cse.psu.edu> Date: Mon, 23 Apr 2001 12:09:21 +0100 Topicbox-Message-UUID: 8b6f64c4-eac9-11e9-9e20-41e7f4b1d025 >>okamoto@granite.cias.osakafu-u.ac.jp wrote: >>> I wonder why C99 employed that int main(), >>Existing practice, tracable back to UNIX. although it was possible to return a status from main by 6th edition (in 5th edition returning from main did exit(0)), and only su included return from main, arguably wrongly in 5th edition and definitely so in 6th. when i looked recently, i could find only two commands using it in 7th edition (makekey and graph, both returning 0). the UNIX programming paper encouraged the use of exit to ensure reliable exit status for a caller. return from main seemed to me to be used mainly by the System III/V crowd, rather later. it's unfortunately more error prone than void/exit. for instance, it was common to forget fflush() in the presence of setbuf/setvbuf in main for an auto buffer and worse, that sometimes `worked' (until ported). i like the plan 9 conventions, myself.