9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: "Douglas A. Gwyn" <gwyn@arl.army.mil>
To: 9fans@cse.psu.edu
Subject: Re: [9fans] the declaration of main()
Date: Fri, 27 Apr 2001 09:13:48 +0000	[thread overview]
Message-ID: <3AE89F46.2851BE15@arl.army.mil> (raw)
In-Reply-To: <20010426210148.4FA2719A2B@mail.cse.psu.edu>

forsyth@caldo.demon.co.uk wrote:
> the C compilers knew nothing of main, and if 7th edition really was the ancestral
> root of most other implementations (which isn't so, because there were
> some before 7th edition), they wouldn't have needed the invention
> of EXIT_FAILURE and EXIT_SUCCESS.

The C *implementations* certainly knew of main, as that is how
the user-provided program gets invoked by the C run-time
start-up module.  The ancestry has to do with the K&R book
and the influence of the UNIX interfaces upon implementors on
other platforms.  int main(argc,argv) might not be the best
interface for a specific platform, but it was (and is)
certainly standard for hosted environments (and some standalone
ones).  The int value returned by main (also passed to the
parent via exit) had certain conventional meanings on UNIX,
and as of 7th Edition it was standard for 0 to mean success
and various small positive numbers to indicate kinds of failure.
Platforms like VAX/VMS already had carefully designed process
status code schemes, for example on VMS a value of 1 actually
meant success.  Through long discussions (arguments) X3J11 was
able to engineer a solution that would work adequately on all
the existing platforms; we figured out a way for VMS to allow
0 to be returned and still indicate success, although they
would prefer a different code (that could be assigned to the
EXIT_SUCCESS macro).  Standardization is often like this; the
affected parties negotiate a mutually acceptable solution that
avoids invalidating (much of) their own customers' existing code.

As someone who has invested a lot of effort over decades to
this area, I find it frustrating when I encounter people who
don't realize that the C standard reflects a lot more than the
small amount of thought that they themselves have given the
matter.  There are good reasons behind the specifications,
and you make a heck of a lot less trouble for others if you
conform to the specifications insofar as possible.


  reply	other threads:[~2001-04-27  9:13 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-04-26 20:58 forsyth
2001-04-27  9:13 ` Douglas A. Gwyn [this message]
2001-04-27 14:48   ` Boyd Roberts
2001-04-27 16:22     ` Douglas A. Gwyn
2001-04-27 18:24       ` William K. Josephson
2001-04-30  9:23         ` Douglas A. Gwyn
2001-04-27 19:38       ` Boyd Roberts
2001-04-28 15:54       ` Greg Hudson
2001-04-28 16:39         ` Dan Cross
2001-04-28 17:06           ` Boyd Roberts
2001-04-30  9:25           ` Douglas A. Gwyn
  -- strict thread matches above, loose matches on Subject: below --
2001-04-30 12:05 rob pike
2001-04-30 10:44 forsyth
2001-04-28 18:44 forsyth
2001-04-30  9:24 ` Douglas A. Gwyn
2001-04-28 17:57 forsyth
2001-04-28 22:28 ` Dan Cross
2001-04-30  9:25 ` Douglas A. Gwyn
2001-04-27  6:57 nemo
2001-04-26 19:42 Russ Cox
2001-04-26 20:32 ` Dan Cross
2001-04-26 22:03 ` Boyd Roberts
2001-04-27  9:13 ` Douglas A. Gwyn
2001-04-26 18:23 forsyth
2001-04-26 19:17 ` Mike Haertel
2001-04-26 23:50   ` Boyd Roberts
2001-04-27 14:41     ` Douglas A. Gwyn
2001-04-27 15:40       ` Boyd Roberts
2001-04-27  9:12 ` Douglas A. Gwyn
2001-04-24 10:32 rog
2001-04-24 18:03 ` Steve Kilbane
2001-04-24  8:10 forsyth
2001-04-26 15:55 ` Douglas A. Gwyn
2001-04-24  0:59 okamoto
2001-04-24  3:08 ` Boyd Roberts
2001-04-23 19:33 dmr
2001-04-23 11:09 forsyth
2001-04-23 11:31 ` Boyd Roberts
2001-04-24  9:02 ` Douglas A. Gwyn
2001-04-24 12:09   ` Boyd Roberts
2001-04-26 16:05     ` Douglas A. Gwyn
2001-04-26 18:12       ` Boyd Roberts
2001-04-26 23:55       ` Boyd Roberts
2001-04-24 17:43   ` Greg Hudson
2001-04-26 15:55     ` Douglas A. Gwyn
2001-04-12  6:28 okamoto
2001-04-23  8:44 ` Douglas A. Gwyn
2001-04-23  8:48 ` Boyd Roberts
2001-04-12  6:22 YAMANASHI Takeshi
2001-04-12  6:25 ` andrey mirtchovski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3AE89F46.2851BE15@arl.army.mil \
    --to=gwyn@arl.army.mil \
    --cc=9fans@cse.psu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).