Article View: alt.msdos.programmer
Article #1186Re: Pascal program works but not C program!
From: The Amorphous Mass
Date: Sat, 20 Jan 1996 01:56
Date: Sat, 20 Jan 1996 01:56
31 lines
2327 bytes
2327 bytes
On 18 Jan 1996, Shadow.King wrote:
> : > void main(int argc,char *argv[])
> : ^-----------------------------This one too, but not too serious
> This isn't really a problem, it's usually just the error code that the
> program returns to dos when it exits.
^^^
Most (all?) implementations of MS-DOS ignore the return codes from
programs, but then MS-DOS puts a great deal of trust in the programmer
not to blow the machine up. By contrast DEC C for VMS, which manages memory
very meticulously, refuses to compile void main() even without strict
ANSI compliance set -- VMS _always_ wants to know whether the program
completed without difficulty and that's all there is to it. VMS tends to
run on multi-user machines where error recovery (or hard crashes) could be
rather costly.
> As far as I know it doesn't HAVE to
> do this so just void main should be fine, I usually do the saem thing
> with simple programs that don't need to set the error level on exit and
> I've had no problems whatsoever with it. It is if the program is supposed
> to return an error level though.
In addition to the practical problems of not returning error codes, the
ANSI C code defines main to return int. Any C program that doesn't exhibits
undefined behavior from the declaration of main() all the way to the end,
as far as the C language is concerned.
/**James Robinson***********************
"If a fatal error occurs, the program should not be allowed to continue."
-- Oracle Pro*C User's Guide *************james-robinson@uiowa.edu**/
Technical Details
Message-ID:
<Pine.A32.3.91.960119194520.147551A-100000@red.weeg.uiowa.edu>Path:
arc1-ca.pugleaf.net!red.weeg.uiowa.edu!robinsonReferences:
<4cdpr2$psi@lugb.latrobe.edu.au> <Pine.SV4.3.91-heb-2.04.960104114930.16292A-100000@cs.technion.ac.il> <4dmpv0$t77@fangz.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!red.weeg.uiowa.edu!robinson From: The Amorphous Mass <robinson@blue.weeg.uiowa.edu> Newsgroups: alt.msdos.programmer,comp.lang.c Subject: Re: Pascal program works but not C program! Date: Fri, 19 Jan 1996 19:56:08 -0600 Organization: University of Iowa, Iowa City, IA, USA Distribution: world Message-ID: <Pine.A32.3.91.960119194520.147551A-100000@red.weeg.uiowa.edu> References: <4cdpr2$psi@lugb.latrobe.edu.au> <Pine.SV4.3.91-heb-2.04.960104114930.16292A-100000@cs.technion.ac.il> <4dmpv0$t77@fangz.com> NNTP-Posting-Host: red.weeg.uiowa.edu Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Sender: robinson@red.weeg.uiowa.edu In-Reply-To: <4dmpv0$t77@fangz.com>