From: "John G. Volan" <johnvolan@sprintmail.com>
Subject: Re: Address to function pointer conversion
Date: 1997/06/17
Date: 1997-06-17T00:00:00+00:00 [thread overview]
Message-ID: <33A74403.4B7C@sprintmail.com> (raw)
In-Reply-To: dewar.866334558@merv
Robert Dewar wrote (quoting me):
>
> John says
> ~
> <<Hmm, I think the answer may be that this sort of thing might just be
> beyond the scope of the Ada95 standard. In other words, this may be an
> implementation-specific (maybe even an OS-specific) thing not defined by
> Ada95. There may be no guaranteed portable way to take the address of a
> routine (I assume imported from some other language, such as C) and turn
> it into an access-to-subprogram. In that case, if you have an
> implementation specific solution that works, you may just have to live
> with the lack of portability.
> >>
Later on in this same post which Robert quoted, I suggested:
> type Callback_Access_Type is access procedure;
> pragma Convention (C, Callback_Access_Type); -- ** is this right?
>
> function Get_Callback return Callback_Access_Type;
> pragma Import (C, Get_Callback, "getCallback");
>
> ** What I don't know here is whether this Convention pragma is correct.
> But if it is, then this would be a guaranteed portable mechanism for
> doing what you want.
In his reply, Robert wrote:
> If the address is coming from C, then I think the following should be quite
> portable:
>
> type x is access procedure ....
> pragma Convention (C, X);
>
> function Get_Address return x;
> pragma Import (C, Get_Address);
Excellent! Looks just like what I wrote.
> Now your compiler might reject the pragma Convention on X, but it is reasonable
> that it shouold be supported, and if it is supported, then it should work.
>
> Notice this general approach, instead of importing some foreign gizmo from C
> like an address, import it in properly typed form, but apply pragma Convention
> C to the type.
>
> This is generally what should be done for access types as well when
> communicating with C.
Thank you Robert, that answers my question. I didn't know whether this
pragma was available for access-to-subprogram types. (I was making an
informed guess.)
------------------------------------------------------------------------
Internet.Usenet.Put_Signature
(Name => "John G. Volan",
Employer => "Texas Instruments Advanced C3I Systems, San Jose, CA",
Work_Email => "jvolan@ti.com",
Home_Email => "johnvolan@sprintmail.com",
Slogan => "Ada95: World's *FIRST* International-Standard OOPL",
Disclaimer => "My employer never defined these opinions, so using " &
"them would be totally erroneous...or is that just " &
"nondeterministic behavior now? :-) ");
------------------------------------------------------------------------
next prev parent reply other threads:[~1997-06-17 0:00 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
1997-06-13 0:00 Address to function pointer conversion Michael Paus
1997-06-13 0:00 ` John G. Volan
1997-06-14 0:00 ` Robert Dewar
1997-06-17 0:00 ` John G. Volan [this message]
1997-06-20 0:00 ` Robert Dewar
1997-06-24 0:00 ` Matthew Heaney
1997-06-24 0:00 ` Robert Dewar
1997-06-25 0:00 ` Michael Paus
1997-06-13 0:00 ` Samuel Mize
1997-06-14 0:00 ` Robert Dewar
1997-06-14 0:00 ` Robert Dewar
1997-06-16 0:00 ` Michael Paus
1997-06-16 0:00 ` Robert Dewar
1997-06-16 0:00 ` Samuel Mize
1997-06-16 0:00 ` Robert A Duff
1997-06-17 0:00 ` Robert Dewar
1997-06-17 0:00 ` Samuel Mize
1997-06-20 0:00 ` Robert Dewar
1997-06-20 0:00 ` Robert Dewar
1997-06-16 0:00 ` Robert A Duff
1997-06-14 0:00 ` Robert A Duff
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox