home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 2590 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.9 KB  |  56 lines

  1. Newsgroups: comp.sys.amiga.programmer
  2. Path: chang.unx.sas.com!walker
  3. From: walker@chang.unx.sas.com (Doug Walker)
  4. Subject: Re: C compiler problem
  5. Sender: news@unx.sas.com (Noter of Newsworthy Events)
  6. Message-ID: <DM5I1y.J46@unx.sas.com>
  7. Date: Fri, 2 Feb 1996 13:41:58 GMT
  8. X-Nntp-Posting-Host: chang.unx.sas.com
  9. References: <4ek3b2$a5k@nntp.novia.net> <3005pbd60.alamito@marketgraph.xs4all.nl> <4eqe9n$jsa@odin.diku.dk>
  10. Organization: SAS Institute Inc.
  11.  
  12. In article <4eqe9n$jsa@odin.diku.dk>,
  13. Torsten Poulin Nielsen <torsten@diku.dk> wrote:
  14. >rvg@marketgraph.xs4all.nl (Ruud van Gaal) writes:
  15. >
  16. >>In <4ek3b2$a5k@nntp.novia.net> tsyslo@oasis.novia.net (Tony Syslo) wrote:
  17. >
  18. >>>int main()
  19. >
  20. >>void main(void) is better prototyped in C. C++ might use void main()
  21. >
  22. >Doesn't ANSI say int main()? At least void main break under some
  23. >compilers.
  24. >
  25.  
  26. ANSI forbids the compiler to provide a prototype for main(), so either
  27. will compile.  However, ANSI states that main() should be declared one
  28. of two ways:
  29.  
  30.    int main(int argc, char *argv[]);
  31.    
  32.    int main(void); 
  33.  
  34.    (See 2.1.2.2 in the ANSI standard for C for details.)
  35.  
  36. Under some implementations, declaring main as void will cause a trash
  37. return value to be sent to the system after the program exits, which
  38. in turn may cause the system to believe that the program has failed.
  39. This was a problem with SAS/C 6.50, but we fixed it in later versions
  40. by forcing the compiler to generate a 0 in register d0 upon the return
  41. of main() if it was declared void.
  42.  
  43. (Arguably we should have let it fail, but previous versions of SAS/C did
  44. not have the failure behavior, so we judged it more important to
  45. preserve backward compatibility than to force the user to recognize
  46. his error.)
  47.  
  48. -- 
  49.   *****                    / walker@unx.sas.com
  50.  *|_o_o|\\     Doug Walker<  BIX, Portal: djwalker
  51.  *|. o.| ||                \ AOL: weissblau
  52.   | o  |//     
  53.   ====== 
  54. Any opinions expressed are mine, not those of SAS Institute, Inc.
  55.  
  56.