comp.lang.ada
 help / color / mirror / Atom feed
* Interfaces.C.Strings_Chars_Ptr as an out mode parameter
@ 1999-06-10  0:00 David C. Hoos, Sr.
  1999-06-11  0:00 ` Tucker Taft
  1999-06-11  0:00 ` dennison
  0 siblings, 2 replies; 3+ messages in thread
From: David C. Hoos, Sr. @ 1999-06-10  0:00 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1275 bytes --]

RM B.3.1 (1) may have something important to say by
what it does _not_ say, viz. :

The package Interfaces.C.Strings declares types and
subprograms allowing an Ada program to allocate,
reference, update, and free C-style strings. In
particular, the private type chars_ptr corresponds
to a common use of �char *� in C programs, and an
object of this type can be passed to a subprogram to
which pragma Import(C,...) has been applied, and for
which �char *� is the type of the argument of the C
function.

What is does _not_ say is that an object of this
type can be passed to a  subprogram to which pragma
Export(C,...) has been applied, and for which
�char *� is the type of the argument of the C
function.

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 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.

What say ye?














^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1999-06-11  0:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
1999-06-11  0:00 ` dennison

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