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