comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@merv.cs.nyu.edu (Robert Dewar)
Subject: Re: Address to function pointer conversion
Date: 1997/06/14
Date: 1997-06-14T00:00:00+00:00	[thread overview]
Message-ID: <dewar.866334558@merv> (raw)
In-Reply-To: 33A1831C.269F@sprintmail.com


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.
 >>
~
~
~
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);

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.





  reply	other threads:[~1997-06-14  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 ` Samuel Mize
1997-06-14  0:00   ` Robert Dewar
1997-06-13  0:00 ` John G. Volan
1997-06-14  0:00   ` Robert Dewar [this message]
1997-06-17  0:00     ` John G. Volan
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-14  0:00 ` Robert Dewar
1997-06-16  0:00   ` Michael Paus
1997-06-16  0:00     ` Robert A Duff
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-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