home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / cplus / 13214 < prev    next >
Encoding:
Text File  |  1992-09-02  |  2.0 KB  |  44 lines

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