From: tmoran@acm.org
Subject: Re: Ada to C Interface: Passing Pointers Via System.Address
Date: Tue, 11 Jan 2005 21:09:42 -0600
Date: 2005-01-11T21:09:42-06:00 [thread overview]
Message-ID: <5_SdnaIyCMxrCXncRVn-qg@comcast.com> (raw)
In-Reply-To: 8e19522cfe30bb2ccbfe1393fdd6b235@localhost.talkaboutprogramming.com
> My C functions return pointers to data structures (very large structures).
> I need to then pass the pointer to the data struct to the Ada code and
> back into other C functions. There is no interaction with the data
> structure in the Ada code except to pass the pointer from one C function
> to another.
If the data being passed through Ada is a black box to Ada, why not
just declare a type of the appropriate size, eg
type C_Thing is range 0 .. 2**32-1;
for C_Thing'size use 32;
for the Ada code - Ada doesn't need to know if the thing is a pointer,
address, segment:offset, whatever.
> I have been trying to use the C interface pragma and return the pointers
> from C into an Ada System.Address back into the correct pointer type.
If you declare something to be an Ada access type, and use a pragma
Convention C, the compiler should do the Right Thing. Note that a
System.Address might not be the right thing (say if System.Address was a
segment:offset while the C pointer was just an offset in a fixed segment).
> So far I have not been able to get this to work properly.
What kind of error are you getting?
next prev parent reply other threads:[~2005-01-12 3:09 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-01-12 2:16 Ada to C Interface: Passing Pointers Via System.Address ReversedBias
2005-01-12 3:09 ` tmoran [this message]
2005-01-12 7:36 ` ReversedBias
2005-01-12 8:38 ` tmoran
2005-01-12 15:50 ` Mark Lorenzen
2005-01-13 17:14 ` Martin Krischik
2005-01-13 1:25 ` Jeffrey Carter
2005-01-13 3:05 ` Steve
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox