comp.lang.ada
 help / color / mirror / Atom feed
From: Samuel Mize <smize@link.com>
Subject: Re: Address to function pointer conversion
Date: 1997/06/16
Date: 1997-06-16T00:00:00+00:00	[thread overview]
Message-ID: <33A5B0B3.7EA663D3@link.com> (raw)
In-Reply-To: dewar.866484497@merv


[quotations reformatted for line length]

Robert Dewar wrote:
> 
> Michael said
> 
> <<The problem which I have mentioned in my original post arises
> when you want to interface an Ada program to a C function which
> can return pointers to different functions ...
...
> [unchecked conversion] may also be problematic and is not
> portable. The only portable solution I see at the moment is to
> import the dlsym function several times for each anticipated
> function pointer type. This is not a very nice solution but I
> think it should work.>>
> 
> Seems a nice solution to me, and indeed is entirely the
> appropriate solution in a strongly typed language!

I would agree EXCEPT -- dlsym is returning an address at run time,
so you can't use pragma Import.  You still have the problem, how
do you call this address from Ada?

It seems to me that you need a C function that takes an address
and calls the function at that address.  You can then pragma
Import that function.  If they're all "void FUNCTION (void)"
this could be one C function.  If they have different profiles,
you would have several C interface functions with parameters,
that call the function at "address" with the same parameters.

Am I missing something simpler?

Sam Mize

--
-- Samuel Mize    (817) 619-8622    smize@link.com    "Team Ada"
-- Hughes Training Inc.  PO Box 6171 m/s 400, Arlington TX 76005




  reply	other threads:[~1997-06-16  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
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 [this message]
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