comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@cs.nyu.edu (Robert Dewar)
Subject: Re: Calling C function with structure parameter from ADA
Date: 1995/04/06
Date: 1995-04-06T00:00:00+00:00	[thread overview]
Message-ID: <dewar.797190489@gnat> (raw)
In-Reply-To: 3lbu1o$n3p@theopolis.orl.mmc.com

T.E.D. assumes that C passes structures by address. This is wrong, it varies
from one machine environment to another.

The RM essenstially repeats this misconception by requiring Ada to pass
a record by address for Convention C, thus, on some machines ensuring
that Ada is incompatible with C.

Actually this is not a requirement, it is implementation advice.

It is also one of the few cases in which GNAT quite deliberately declines
to follow the implementation advice in the RM.

In GNAT, if you make a procedure convention C, then we pass records
EXACTLY THE SAME WAY THAT C would pass them, guaranteeing compatibility
with C -- This seems a much better approach, and for example, simply
and directly solves the original poster's problems.

I hope other compilers will make this same sensible decision. If not,
watch out, your Ada compiler may go out of its way to ensure that it
is incompatible with C!

Note: in discussion of this point earlier on, the MRT suggested simply
changing the C code to pass the structure by pointer, but that is
irrelevant to the task of creating bindings to existing C interfaces,
where it is essential to be able to model C exactly.

I suppose we could have two conventions

  C
  C_Done_Right

but that seems unnecessary :-)





  reply	other threads:[~1995-04-06  0:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1995-03-28 17:22 Calling C function with structure parameter from ADA C.G. Williams
1995-03-29  0:00 ` Theodore Dennison
1995-04-06  0:00   ` Robert Dewar [this message]
1995-04-07  0:00     ` Chris Warack <sys mgr>
1995-04-07  0:00       ` Robert Dewar
     [not found]     ` <D6pwGs.8wE@thomsoft.com>
1995-04-19  0:00       ` Fergus Henderson
replies disabled

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