From: Stephen Leake <Stephen.Leake@gsfc.nasa.gov>
Subject: Re: How do I get this to work??
Date: 1999/01/07
Date: 1999-01-07T00:00:00+00:00 [thread overview]
Message-ID: <uhfu2bzmo.fsf@gsfc.nasa.gov> (raw)
In-Reply-To: 770ifd$qui$1@goblin.uunet.ca
"Chris Warwick" <chris.warwick@cdcgy.com> writes:
> Stephen Leake wrote in message ...
>
> >Why does Close_Port need a pointer to a Session? If you are passing
> >Session to C code, you should probably use 'Address rather than
> >'access. Or, define Close_Port to take an access parameter:
As Robert Dewar pointed out, this was bad advice. Aparently too much
xmas turkey clogged the arteries to my brain :)
The current advice (I believe) is to declare the Ada procedure to take
an 'in' or 'in out' parameter, and let the compiler pass this to the C
code by reference.
This only works if the C code doesn't allow a null pointer as a valid
option; the correct way to pass a parameter that can either be a null
pointer or a pointer to an object is with an access type parameter,
and 'Unchecked_Access.
> I am indeed passing this to some C code, and I realize that what I am doing
> is cheating, just a little. The reason is I can't seem to get the stuff to
> the C function by value, if I pass it by reference its happy, but it barfs
> when I try to do it by value.
Post the code that fails to "pass by value"; maybe we can tell you
what's wrong with it.
> My old trick of translating pointers into Ada types by creating a function
> to return the record by value also doesn't work...
>
> >function Close_Port (Session : access Session_Type);
> >
> >If you really, really need the interface you've given,
> >'unchecked_access will eliminate the error message.
>
>
> Thanks, it does indeed eliminate the error, but it leaves me with a bad
> taste. Somewhat like resorting to an unchecked_conversion.
I agree with the other comments here; the bad taste is from not
knowing what will happen to the pointer when you pass it to C. That's
why it is "unchecked".
> Is there a "proper" way to do this, or am I stuck with the unchecked
> solution?
If you don't need to be able to pass a null pointer, passing as an
'in' or 'in out' parameter should work, and would be the proper
solution.
-- Stephe
next prev parent reply other threads:[~1999-01-07 0:00 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-01-04 0:00 How do I get this to work?? Chris Warwick
1999-01-05 0:00 ` Tom Moran
1999-01-05 0:00 ` Chris Warwick
1999-01-05 0:00 ` Stephen Leake
1999-01-05 0:00 ` Tom Moran
1999-01-06 0:00 ` robert_dewar
1999-01-06 0:00 ` Tom Moran
1999-01-07 0:00 ` robert_dewar
1999-01-07 0:00 ` Tom Moran
1999-01-10 0:00 ` robert_dewar
1999-01-06 0:00 ` Larry Kilgallen
1999-01-06 0:00 ` Tom Moran
1999-01-06 0:00 ` Tom Moran
1999-01-07 0:00 ` robert_dewar
1999-01-07 0:00 ` Tom Moran
1999-01-10 0:00 ` robert_dewar
1999-01-10 0:00 ` Tom Moran
1999-01-10 0:00 ` robert_dewar
1999-01-10 0:00 ` robert_dewar
1999-01-10 0:00 ` Tom Moran
1999-01-10 0:00 ` Pat Rogers
1999-01-06 0:00 ` robert_dewar
1999-01-06 0:00 ` Chris Warwick
1999-01-06 0:00 ` Tom Moran
1999-01-07 0:00 ` robert_dewar
1999-01-09 0:00 ` Chris Warwick
1999-01-09 0:00 ` Simon Wright
1999-01-10 0:00 ` robert_dewar
1999-01-11 0:00 ` Simon Wright
1999-01-16 0:00 ` Chris Warwick
1999-01-16 0:00 ` robert_dewar
1999-01-18 0:00 ` Chris Warwick
1999-01-18 0:00 ` Matthew Heaney
1999-01-16 0:00 ` Simon Wright
1999-01-16 0:00 ` Matthew Heaney
1999-01-16 0:00 ` robert_dewar
1999-01-18 0:00 ` Chris Warwick
1999-01-18 0:00 ` robert_dewar
1999-01-18 0:00 ` Tucker Taft
1999-01-19 0:00 ` Chris Warwick
1999-01-19 0:00 ` Tom Moran
1999-01-19 0:00 ` Stephen Leake
1999-01-19 0:00 ` robert_dewar
1999-01-20 0:00 ` Jeff Carter
1999-01-20 0:00 ` robert_dewar
1999-01-21 0:00 ` Chris Warwick
1999-01-18 0:00 ` dennison
1999-01-18 0:00 ` dennison
1999-01-18 0:00 ` Matthew Heaney
1999-01-09 0:00 ` Brian Rogoff
1999-01-10 0:00 ` Matthew Heaney
1999-01-07 0:00 ` Stephen Leake [this message]
1999-01-08 0:00 ` Simon Wright
1999-01-06 0:00 ` Simon Wright
1999-01-22 0:00 ` Nick Roberts
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox