Re: print "foo" without using ;
- From: mwojcik@xxxxxxxxxxx (Michael Wojcik)
- Date: 29 Aug 2005 15:06:39 GMT
In article <430fc460$0$82713$892e0abb@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>, Thad Smith <ThadSmith@xxxxxxx> writes:
> Fao, Sean wrote:
>
> > Mostly off-topic, but perhaps surprising is the fact that Microsoft
> > actually accepts void as a valid return type.
>
> Not surprising here. The main reason that an OS (or other calling
> environment) wouldn't accept a void function, rather than an function
> returning int is that the calling convention is incompatible.
It's not a matter for the OS, but one for the implementation. An
implementation which runs on top of an OS might disallow "void main"
as an alternative, non-standard form because of some issue with that
OS, but there are certainly other possibilities. For example, an
implementation might disallow it because its authors wish to enforce
explicitly returning a valid status.
I'm curious to know how you determined that "calling convention"
(which is not covered by the standard) is the "main reason" for
disallowing alternative forms of main.
> When ANSI C was being developed and a void
> type added, implementors wisely did not make calling void functions
> incompatible with calling an int function.
In what sense? The standard certainly makes calling a function
incorrectly - ie, with an incorrect prototype in scope, or without
a prototype in scope if the function is not declared in a manner
compatible with a non-prototyped function - an error, which sounds
like "incompatible" to me.
> Of course, such calling compatibility isn't guaranteed,
If the standard doesn't guarantee compatibility, then it makes it
incompatible. There is no middle. "Happens to work" is a possible
result of undefined behavior; it doesn't demonstrate anything about
either the intentions or requirements of the standard.
> What
> implementations are you familiar with in which the calling convention
> for a void function and an int function are different?
EPM C for the AS/400, for one.
> I am not aware of any.
Anecdotal evidence, as always, demonstrates nothing about the C
language.
--
Michael Wojcik michael.wojcik@xxxxxxxxxxxxxx
When [Columbus] landed on America it was more like an evasion than a
discovery. -- Matt Walsh
.
- References:
- print "foo" without using ;
- From: Rajesh
- Re: print "foo" without using ;
- From: Chris Dollin
- Re: print "foo" without using ;
- From: Rajesh
- Re: print "foo" without using ;
- From: Randy Howard
- Re: print "foo" without using ;
- From: Fao, Sean
- Re: print "foo" without using ;
- From: Thad Smith
- print "foo" without using ;
- Prev by Date: Re: while (1) vs. for ( ;; )
- Next by Date: Re: Style isn't always religious
- Previous by thread: Re: print "foo" without using ;
- Next by thread: Re: print "foo" without using ;
- Index(es):
Relevant Pages
|