comp.lang.ada
 help / color / mirror / Atom feed
From: Tucker Taft <stt@averstar.com>
Subject: Re: Interfaces.C.Strings_Chars_Ptr as an out mode parameter
Date: 1999/06/11
Date: 1999-06-11T00:00:00+00:00	[thread overview]
Message-ID: <37611FB6.BBFF0F09@averstar.com> (raw)
In-Reply-To: 7jpe2e$m7i@hobbes.crc.com

David C. Hoos, Sr. wrote:
> ...
> So... the question is.. if one wishes to have a
> procedure with a profile of, say:
> 
> procedure My_Proc (Result : out Interfaces.C.Strings.Chars_Ptr);
> 
> is it legal to export it like so:
> 
> pragma Export (C, My_Proc, "My_Proc");
> 
> where the C prototype is void My_Proc (char * result);

The C prototype should be:  void My_Proc (char ** result);
because "out" parameters are given an extra level of indirection.
The caller must also use "&" on the actual parameter (in C).

> The results I'm having are that if the exported procedure
> is called from Ada, everything works as expected.
> 
> If called from C, a Segmentation fault occurs at the
> point where the out mode parameter is assigned its
> value in the Ada procedure My_Proc.

Doesn't surprise me.

> What say ye?

-- 
-Tucker Taft   stt@averstar.com   http://www.averstar.com/~stt/
Technical Director, Distributed IT Solutions  (www.averstar.com/tools)
AverStar (formerly Intermetrics, Inc.)   Burlington, MA  USA




  reply	other threads:[~1999-06-11  0:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-06-10  0:00 Interfaces.C.Strings_Chars_Ptr as an out mode parameter David C. Hoos, Sr.
1999-06-11  0:00 ` Tucker Taft [this message]
1999-06-11  0:00 ` dennison
replies disabled

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