Subject: Re: main return...
To: None <current-users@NetBSD.ORG>
From: Ty Sarna <tsarna@endicor.com>
List: current-users
Date: 03/26/1996 07:38:28
In article <199603260101.TAA12786@solutions.solon.com>,
Peter Seebach <seebs@solon.com> wrote:
> No, there are *not* cases in which it is all right; it is invalid
> standard C. If you declare main to return int, but return no
Well actually if you want to get *really* picky, there *is* a case (a
freestanding environment, per 5.1.2.2 ISO) where the standard says the
name, arguments, and return value of the main function may be defined by
the implementation as whatever it wants. Thus main() in the kernel
doesn't have to follow those rules to be valid C, and doesn't even have
to be called main. There are many rules that don't apply in the kernel,
because it is a "freestanding" environment.
Still though, void main in "hosted" (~= userland) programs is SO common
that the standard might as well be changed to allow it. I don't see that
it would really hurt anything if it were changed that way. Shoot, look
at all the quite experienced C programmers who don't know it's not
allowed!