Re: Ada array vs C pointer (call by reference)
- From: Keith Thompson <kst-u@xxxxxxx>
- Date: 27 Jun 2008 09:11:24 -0700
Maciej Sobczak <see.my.homepage@xxxxxxxxx> writes:
On 27 Cze, 04:55, Adam Beneschan <a...@xxxxxxxxxx> wrote:
Oh, and you probably want to use Interfaces.C.C_Float instead of the
Ada type "Float", to ensure that you're using the same kind of float
that the C routine expects.
Don't get me wrong, but I find it a bit of handwaving.
Ada *cannot* guarantee that Interfaces.C.C_Float is the *right* float,
because it does not verify how the C code was compiled and there is a
lot of freedom given to C implementers in this area.
Same for all other types.
No, Ada can't guarantee it directly. Instead, Ada requires the
implementation to guarantee it.
In reality we have to rely on some external knowledge about the
implementation - but then, Interfaces.C.XXX have little added value,
because we might as well have the same knowledge about types from
Standard.
Is there any implementation where Interfaces.C.int has different
properties than Integer?
I don't know, and I suggest that you don't know either.
To answer that question, you'd have to look at every existing Ada
implementation, and at every existing C implementation that targets
the same systems.
To answer it usefully, you'd also have to look at every *future*
implementation on which your code might run.
There is no fundamental reason to assume that Ada's Integer and C's
int have the same properties. That's exactly why Interfaces.C exists.
Look at it this way. You have the choice of using
Interfaces.C.C_Float, which (assuming the Ada implementation gets it
right), is guaranteed to match C's float, or of using Float, which has
no such guarantee (but saves a little typing). Why would you even
consider using Float?
--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
.
- Follow-Ups:
- Re: Ada array vs C pointer (call by reference)
- From: Maciej Sobczak
- Re: Ada array vs C pointer (call by reference)
- From: Robert A Duff
- Re: Ada array vs C pointer (call by reference)
- References:
- Ada array vs C pointer (call by reference)
- From: Adrian Hoe
- Re: Ada array vs C pointer (call by reference)
- From: Adam Beneschan
- Re: Ada array vs C pointer (call by reference)
- From: Maciej Sobczak
- Ada array vs C pointer (call by reference)
- Prev by Date: Re: Interfacing to C and long long data type
- Next by Date: Re: Ada array vs C pointer (call by reference)
- Previous by thread: Re: Ada array vs C pointer (call by reference)
- Next by thread: Re: Ada array vs C pointer (call by reference)
- Index(es):
Relevant Pages
|
Loading