Sender: Vik DOT Heyndrickx AT rug DOT ac DOT be Message-ID: <35862AD6.7C5D@rug.ac.be> Date: Tue, 16 Jun 1998 10:20:38 +0200 From: Vik Heyndrickx MIME-Version: 1.0 To: Charles Marslett CC: DJ Delorie , nate AT cartsys DOT com, djgpp-workers AT delorie DOT com Subject: Re: inb/outb References: <199806112347 DOT TAA11699 AT delorie DOT com> <3580FC0A DOT 4D10 AT rug DOT ac DOT be> <3581566D DOT A3E0262A AT vlsi DOT com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Precedence: bulk Charles Marslett wrote: > > Vik Heyndrickx wrote: > > > > If I'm correct, the compiler assumes the default when a prototype is > > omitted. Since the default is ``int'', isn't omitting a prototype > > equally as bad as providing some prototype? > > Not quite. If you provide a prototype, then you cannot override > it with another (or I don't know how you undef a prototype). While > if you omit the prototype, you can define it later so long as the > function is not referenced before the prototype definition. Suppose you have somewhere in a file the following definition double foo (double a, unsigned r) { while (r--) a += a; return a; } Suppose you have in ***another file*** a call to this function but no prototype was given yet: double r = foo (7, 3); Since this 7 is an integral constant and no floating point constant it will occupy only #sizeof(unsigned) number of bytes on the stack while ``foo'' expects 8 bytes (a double). As a result it won't work. Second example: Suppose that foo_XQ is a function that is available among different platforms, but it tends to have a different interface on many platforms (POSIX's arrows missed it). A function declared (and defined) in one file as: void *foo_XQ (void *, int); In another file (originally written for another platform, on which the function is declared ``void *foo_XQ (int,void *)'') it is assumed foo_XQ will be defined in DJGPP, but DJGPP provides no prototypes for it: void *p; void *r = foo_XQ (7, p); I'd bet this doesn't work. -- \ Vik /-_-_-_-_-_-_/ \___/ Heyndrickx / \ /-_-_-_-_-_-_/ Knight in the Order of the Unsigned Types