comp.lang.ada
 help / color / mirror / Atom feed
From: sjw <simon.j.wright@mac.com>
Subject: Re: Gem 39 - compiler specific?
Date: Sat, 5 Sep 2009 23:54:50 -0700 (PDT)
Date: 2009-09-05T23:54:50-07:00	[thread overview]
Message-ID: <8f30ae6d-29b7-4eb3-809d-70669cb22eea@q7g2000yqi.googlegroups.com> (raw)
In-Reply-To: 79b62678-84b6-49a2-a943-2212658bedfe@l9g2000yqi.googlegroups.com

On Sep 5, 9:45 pm, Maciej Sobczak <see.my.homep...@gmail.com> wrote:

> You meant pragma Import (C, P);

Yes

> B.3/68:
>
> "An Ada access T parameter, or an Ada out or in out parameter of an
> elementary type T, is passed as a t* argument to a C function, where t
> is the C type corresponding to the Ada type T."
>
> This is the only guarantee concerning access types when interfacing
> with C.
> The paragraph is clearly constrained to those types that have some
> corresponding type on the C side. For example access to
> Interfaces.C.int will be passed as int*.
> But I see nothing about access to types that have no C counterpart. In
> particular, access values to class-wide types are not covered at all.
>
> This is the reason why I think that passing address (seen as void* on
> the C side) is the proper way.
> All corrections to this reasoning are highly welcome.

The last time I had to do something like this, I said something like

with Ada.Streams;
package Accessing is

   type Stream_Access is access all
Ada.Streams.Root_Stream_Type'Class;
   for Stream_Access'Size use 32;

   procedure Pass (SA : Stream_Access);
   pragma Import (C, Pass);

end Accessing;

but that was a long time ago, and GNAT now says

accessing.ads:7:20: warning: "Pass.SA" involves a tagged type which
does not correspond to any C type

which is a pretty strong hint!



  reply	other threads:[~2009-09-06  6:54 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-02 20:38 Gem 39 - compiler specific? Maciej Sobczak
2009-09-02 23:20 ` Randy Brukardt
2009-09-03  7:26   ` Dmitry A. Kazakov
2009-09-03 15:26     ` Adam Beneschan
2009-09-03 16:38       ` Dmitry A. Kazakov
2009-09-03 17:27         ` Adam Beneschan
2009-09-03 20:26           ` Dmitry A. Kazakov
2009-09-03 22:06             ` Randy Brukardt
2009-09-04  7:29               ` Dmitry A. Kazakov
2009-09-04 12:07                 ` Maciej Sobczak
2009-09-04 13:06                   ` Dmitry A. Kazakov
2009-09-04 17:18                     ` Dmitry A. Kazakov
2009-09-04 20:34                     ` Maciej Sobczak
2009-09-04 22:41                   ` sjw
2009-09-05 20:45                     ` Maciej Sobczak
2009-09-06  6:54                       ` sjw [this message]
2009-09-03 21:58           ` Randy Brukardt
2009-09-04 17:26           ` Robert A Duff
2009-09-03 21:53     ` Randy Brukardt
2009-09-03  0:12 ` Adam Beneschan
replies disabled

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