www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1998/06/16/04:23:31

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 <Vik DOT Heyndrickx AT rug DOT ac DOT be>
MIME-Version: 1.0
To: Charles Marslett <charles DOT marslett AT vlsi DOT com>
CC: DJ Delorie <dj AT delorie DOT com>, 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>

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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019