comp.lang.ada
 help / color / mirror / Atom feed
From: "David Thompson" <david.thompson1@worldnet.att.net>
Subject: Re: Variable arguments magic in Ada to C code
Date: Sun, 18 Aug 2002 22:43:45 GMT
Date: 2002-08-18T22:43:45+00:00	[thread overview]
Message-ID: <BqV79.18884$Ep6.1469501@bgtnsc05-news.ops.worldnet.att.net> (raw)
In-Reply-To: 87k7mso2lk.fsf@deneb.enyo.de

Florian Weimer <fw@deneb.enyo.de> wrote :
> lutz@iks-jena.de (Lutz Donnerhacke) writes:
...
> Quite a lot of GNU C code breaks when compiled with a conforming
> C compiler because prototypes do not match old-style function
> definitions (I'm not sure if prototypes were allowed at all for
> old-style function definitions before C99).

This is not very clear; I think you mean declarations using
prototype syntax (new in C89/90, like C++) in calling code
for a function whose definition (implementation, body) uses
old-style (K&R1) parameter declaration syntax.  If so, you
_can_ (since C89) write a prototype correctly matching any
definition that was legal in K&R1 -- but you must be careful,
because parameters of "less than normal width" types,
specifically integer types below (signed or unsigned) int
and float (the only floating type below double) were promoted
in K&R1 calls and thus the promoted types must be used
in the prototype to get the correct matching, even though
the definition can be written with the narrower type(s).

gcc will warn about mistakes here if the prototype declaration
is visible at the definition (e.g. by #include'ing the "spec" .h
in the "body", a commonly recommended practice) if you use
-pedantic, at least 2.95.2 which is what I have handy to check.

If this is meant to relate to the earlier posts about vararg versus
non-vararg functions in C, there was and is no K&R1 syntax
for vararg -- the _only_ correct way to call or define/implement
vararg functions in C is with prototype syntax.  (Or of course
a compatible implementation of another language, like Ada.)

--
- David.Thompson 1 now at worldnet.att.net








      reply	other threads:[~2002-08-18 22:43 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-08-05 23:47 Variable arguments magic in Ada to C code Andreas Almroth
     [not found] ` <slrnakv5v0.p2.lutz@taranis.iks-jena.de>
     [not found]   ` <87ptww7yj6.fsf@almroth.com>
     [not found]     ` <slrnal1l8s.pj.lutz@taranis.iks-jena.de>
     [not found]       ` <dstanbro-CDC252.20502007082002@news-server.bigpond.net.au>
2002-08-14  9:05         ` Lutz Donnerhacke
     [not found]       ` <87vg6nj8jd.fsf@almroth.com>
2002-08-16 19:41         ` David Thompson
2002-08-14 10:01   ` Florian Weimer
2002-08-14 11:34     ` Lutz Donnerhacke
2002-08-14 13:13       ` Dale Stanbrough
2002-08-14 13:59       ` Florian Weimer
2002-08-14 14:02         ` Lutz Donnerhacke
2002-08-15 10:09           ` Florian Weimer
2002-08-18 22:43             ` David Thompson [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox