comp.lang.ada
 help / color / mirror / Atom feed
From: Rod Chapman <rod@praxis-cs.co.uk>
Subject: How to pass access parameters to/from C safely/portably?
Date: 1998/06/01
Date: 1998-06-01T00:00:00+00:00	[thread overview]
Message-ID: <3572CB7D.FD6D8084@praxis-cs.co.uk> (raw)


I wonder if anyone out there could advise me on a point of
portability and style with respect to passing
access parameters from C to Ada.

I need to call Ada subprograms from C, passing C pointers which
denote "in" or "out" parameter for Ada.

Assuming I want C to pass Ada a pointer-to-int...is it
better to do:

   procedure XXX ( Ptr : access Interfaces.C.Int );
   pragma Export(C, XXX);

or

   type Ptr_To_Int is access Interfaces.C.Int;

   procedure XXX ( Ptr : in Ptr_To_Int );
   pragma Export(C, XXX);

I read in Barnes' "Programming in Ada 95" that "In order for this check
to be
possible all access parameters carry with them an indication of the
accessibility
of the actual parameter"...this seems to imply that the first option
above
shouldn't work, since C obviously has no idea of how to pass
accessibility
information...is that right?

Oddly, (using ObjectAda 7.1.1), we seem to have made the first scheme
work, but this might be purely luck!

Thanks in advance,
 Rod Chapman
 Praxis Critical Systems
 rod@praxis-cs.co.uk







             reply	other threads:[~1998-06-01  0:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-06-01  0:00 Rod Chapman [this message]
1998-06-05  0:00 ` How to pass access parameters to/from C safely/portably? Rod Chapman
1998-06-06  0:00   ` Robert Dewar
replies disabled

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