comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Re: Dispatching callback handed over to C
Date: Sat, 07 Apr 2012 12:32:33 +0100
Date: 2012-04-07T12:32:33+01:00	[thread overview]
Message-ID: <m2iphbhj5a.fsf@pushface.org> (raw)
In-Reply-To: slrnjo007l.1lme.lithiumcat@sigil.instinctive.eu

Natasha Kerensikova <lithiumcat@gmail.com> writes:

> On 2012-04-05, Randy Brukardt <randy@rrsoftware.com> wrote:
>> In particular, we're talking about the mapping of C to Ada here, and
>> not the underlying design of the C API (which is out of our control
>> anyway). The question is how to map "void *" to Ada?
>>
>> 1) Some convention C access type designating an appropriate Ada type.
>>
>> 2) Some convention C access type designating a dummy Ada type (use 
>> unchecked_conversion as needed on the real types).
>
> What I'm still struggling with is why do I have to settle for #2, or
> what is preventing me from going for #1?
>
>    type Callback_Access is access all Event_Callback'Class;
>    pragma Convention (C, Callback_Access);
>
> Using Callback_Access in a subprogram imported from C trigged the
> following GNAT warning:
>
>         >>> warning: "Imported_Subprogram.Arg" involves a tagged type
> which does not correspond to any C type
>
> I guess since it's "only" a warning, I could just silence. However I
> can't bring myself to silence something I don't understand.
>
> If it's only about the fact that Callback_Access is a C pointer to an
> object with which C subprograms has no way for dealing properly, then
> fine (since in that particular case C code considers it as an opaque
> pointer).

I think that must be it. I did wonder whether a classwide pointer might
be a fat pointer, but one would hope that in that case the compiler
would complain that pointer-to-classwide doesn't fit in a standard C
pointer.

I do seem to remember that, in a similar context - possibly context
parameters to Xt callbacks - a GNAT compiler managed to squeeze what was
normally a fat pointer into a thin one. It was a long time ago.

However, in this case GNAT uses thin (64-bit) pointers for both Ada and
C convention pointers (GCC 4.6.0, x86_64-apple-darwin10).



  reply	other threads:[~2012-04-07 11:32 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-03  7:19 Dispatching callback handed over to C Natasha Kerensikova
2012-04-03  9:04 ` Brian Drummond
2012-04-03  9:21   ` Thomas Locke
2012-04-03  9:37 ` Maciej Sobczak
2012-04-03 12:02   ` Natasha Kerensikova
2012-04-03 14:42     ` Maciej Sobczak
2012-04-03 20:20       ` Randy Brukardt
2012-04-04  7:26         ` Georg Bauhaus
2012-04-04  7:56         ` Natasha Kerensikova
2012-04-04 19:28           ` Randy Brukardt
2012-04-05  8:59             ` Natasha Kerensikova
2012-04-05 21:04               ` Randy Brukardt
2012-04-04 19:55           ` Simon Wright
2012-04-04 11:34         ` Maciej Sobczak
2012-04-04 19:16           ` Randy Brukardt
2012-04-05  7:28             ` Maciej Sobczak
2012-04-05 21:32               ` Randy Brukardt
2012-04-07  8:55                 ` Natasha Kerensikova
2012-04-07 11:32                   ` Simon Wright [this message]
2012-04-07 13:28                     ` Robert A Duff
2012-04-05  9:13             ` Natasha Kerensikova
2012-04-05 21:06               ` Randy Brukardt
2012-04-06  7:30               ` Maciej Sobczak
2012-04-06 11:41                 ` Simon Wright
2012-04-10  7:15                   ` Maciej Sobczak
replies disabled

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