home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!ogicse!lclark!harrison
- From: harrison@lclark.edu (Mark Harrison)
- Newsgroups: comp.lang.c++
- Subject: Re: Turbo C++, function prototypes
- Message-ID: <1992Sep2.171625.13525@lclark.edu>
- Date: 2 Sep 92 17:16:25 GMT
- Article-I.D.: lclark.1992Sep2.171625.13525
- References: <2262@bigfoot.first.gmd.de> <1992Sep1.160816.10309@lclark.edu> <1992Sep2.162728.11201@taumet.com>
- Organization: Lewis & Clark College, Portland OR
- Lines: 32
-
- In article <1992Sep2.162728.11201@taumet.com> steve@taumet.com (Steve Clamage) writes:
- >harrison@lclark.edu (Mark Harrison) writes:
- >
- >>>main's correct return type is 'int'.
- >
- >>It should make no difference whether you try 'int' or 'void' as long as
- >>main() returns the correct value (or doesn't with void.)
- >
- >It ought to make a difference, since the only valid definitions of
- >main() have return type 'int' (explict or implied). This is the case
- >in both Standard C and in C++. If you write, for example,
- > void main(){ }
- >The compiler is obligated to diagnose an error in C and C++.
- >
- >The return value from main() is supposed to be supplied to the calling
- >environment in some implementation-defined way. Some systems appear not
- >to care whether you return a value, but some report error conditions
- >based on the garbage value which main() otherwise implicitly returns.
-
- Well, I have since learned, that you should ALWAYS return a value. But
- still, I have Turbo C/C++ 3.0, and my compiler is NOT obligated to
- diagnose an error. I know because I've used 'void main()', and everything
- compiles & runs just fine. Of couse I've never thought of having others
- run them who might want to put them in some kind of batch file that
- expects a return value.
-
-
- --
- =============================================================================
- Mark Harrison | "We are the Priests, of the Temples of Syrinx
- harrison@sun.lclark.edu | Our great computers fill the hallowed halls."
- -- Me | -- Rush
-