Article View: gnu.gcc.help
Article #53381ANSI prototypes with traditional functions
From: Charlie Hileman
Date: Thu, 09 Jan 1992 15:46
Date: Thu, 09 Jan 1992 15:46
37 lines
1865 bytes
1865 bytes
My company sells a graphics software package that includes a library
of functions. Most of our code is in C, using the traditional
function structure, since we port to many machines without ANSI.
With our library, we provide full ANSI prototypes, for the convenience
of the ANSI users.
The question I have relates to the use of function prototypes for
traditionally-defined functions. Below is a common example, of
promoting a char to an int in the prototype:
void foo (int a);
---
void foo (a)
char a;
{ ... }
Likewise, we must promote char, short, and float parameters in our
prototypes. Otherwise, ANSI-compiled code will send the parameter
list to our functions without promotion, while our
traditionally-defined functions will be expecting promotion.
A blunt solution is to avoid char, short, and float parameters for all
published functions. I consider this non-desirable. However, if we
don't take this path, the published documentation will conflict either
with the prototypes, or with the code.
Is there a book that discuses this specific problem? I imagine this
subject must pop up for any software company that distributes 'C'
libraries with ANSI-function prototypes.
Many thanks!
--Charlie Hileman ARPA: chaz@vicorp.com
V. I. Corporation UUCP: uunet!vicorp!chaz
Northampton, Massachusetts
Technical Details
Message-ID:
<1992Jan9.154610.9305@vicorp.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!vicorp!chazShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 11318c,3519dc9afa78f2e5,start X-Google-Attributes: gid11318c,public X-Google-ArrivalTime: 1992-01-09 08:27:34 PST Newsgroups: gnu.gcc.help Path: arc1-ca.pugleaf.net!sparky!uunet!vicorp!chaz From: chaz@vicorp.com (Charlie Hileman) Subject: ANSI prototypes with traditional functions Message-ID: <1992Jan9.154610.9305@vicorp.com> Organization: V. I. Corporation, Northampton, Massachusetts Distribution: usa Date: Thu, 9 Jan 92 15:46:10 GMT