home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / programm / 2427 < prev    next >
Encoding:
Text File  |  1992-08-21  |  2.4 KB  |  49 lines

  1. Newsgroups: comp.programming
  2. Path: sparky!uunet!usc!elroy.jpl.nasa.gov!ames!agate!linus!linus.mitre.org!church.mitre.org!crawford
  3. From: crawford@church.mitre.org (Randy Crawford)
  4. Subject: Re: ANSI C, was Re: Teaching the basics
  5. Message-ID: <1992Aug22.034214.19539@linus.mitre.org>
  6. Sender: news@linus.mitre.org (News Service)
  7. Nntp-Posting-Host: church.mitre.org
  8. Organization: The MITRE Corporation, McLean, VA
  9. References: <1992Aug21.154839.2664@organpipe.uug.arizona.edu> <1992Aug21.232022.28931@prl.dec.com>
  10. Date: Sat, 22 Aug 1992 03:42:14 GMT
  11. Lines: 36
  12.  
  13. In article <1992Aug21.232022.28931@prl.dec.com> boyd@prl.dec.com (Boyd Roberts) writes:
  14. >In article <1992Aug21.154839.2664@organpipe.uug.arizona.edu>, dave@cs.arizona.edu (Dave Schaumann) writes:
  15. >> 
  16. >> IMHO, you should do it anyway.  Make your own header files with the
  17. >> appropriate prototypes if you need to.
  18. >
  19. >I just can't see the worth in function prototypes.
  20.  
  21. Then you're going to be stuck with zero type checking in your compiler.  Since 
  22. the compiler cannot know what types the arguments are to its functions, it will 
  23. be unable to do the automatic type conversions that ANSI C does.  As in K&R C,
  24. the compiler will promote types to the largest integral type it has, and pass
  25. all user defined types by address (because it doesn't know how large it is).  
  26. This is wasteful and sometimes bug inducing.  You'll have to remember that the 
  27. automatic type conversion is always going on, and may introduce some precision 
  28. loss due to the float -> double -> float operations.
  29.  
  30. >Now, a type checking loader would be a fine thing.
  31. >So just what is the problem here?  Why can't I buy one?
  32.  
  33. You can.  It's called a VAX.  However, in Unix, ld (the linker) has lost all
  34. type information by the time the link occurs.  Unless you change the object
  35. file format to keep argument and function types around after compilation, no 
  36. linker will have the information needed to do the job.  The same is true in DOS.
  37.  
  38. And why would you want to defer the task until the link step?  Don't you _want_ 
  39. to be told ASAP that your argument types don't match those of the function you 
  40. are calling or that you've provided the wrong number of arguments in the call?
  41.  
  42. That's the reasoning behind why compilers and linkers rely on function 
  43. prototypes.
  44. -- 
  45.  
  46. | Randy Crawford        crawford@mitre.org        The MITRE Corporation
  47. |                                                 7925 Colshire Dr., MS Z421
  48. | N=1 -> P=NP           703 883-7940              McLean, VA  22102
  49.