Re: print "foo" without using ;
- From: Joe Wright <jwright@xxxxxxxxxxx>
- Date: Mon, 29 Aug 2005 20:32:45 -0400
Thad Smith wrote:
Utter nonsense. How can you possibly offer such trash in the group where you know the masters live.Fao, Sean wrote:
Mostly off-topic, but perhaps surprising is the fact that Microsoft actually accepts void as a valid return type.
http://msdn.microsoft.com./library/default.asp?url=/library/en-us/vclang98/HTML/_pluslang_program_startup.3a_.the_main_function.asp
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. Since C evolved from K&R, which didn't have void types, and therefore used default int type functions. 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. Of course, such calling compatibility isn't guaranteed, but happens most of the time. What implementations are you familiar with in which the calling convention for a void function and an int function are different? I am not aware of any.
Thad
1. There is no term 'calling environment' in common parlance.
2. The term 'calling convention' is commonly used but you obviously don't know what it means (look it up).
3. As of C89 we are allowed to declare and define generic functions of type void. Nothing to do with calling convention.
The function main() is NOT a generic. It is the real name of your C program. It is called by the command shell and has a 'value' of type int. Not void, int! This was decided among Ken Thompson and Dennis Ritchie circa 1972, three years before Bill, 19 years old in 1975 started Microsoft.
K&R (1978), C89 and C99 all define main() with type int.
--
Joe Wright
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
.- Follow-Ups:
- Re: print "foo" without using ;
- From: Keith Thompson
- Re: print "foo" without using ;
- 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: UnSigned Long
- Next by Date: Re: Problem in Strdup()
- Previous by thread: Re: print "foo" without using ;
- Next by thread: Re: print "foo" without using ;
- Index(es):
Relevant Pages
|