From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=BAYES_05,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,bbbeae4ed07e9626 X-Google-Attributes: gid103376,public From: Samuel Mize Subject: Re: Address to function pointer conversion Date: 1997/06/16 Message-ID: <33A5B0B3.7EA663D3@link.com>#1/1 X-Deja-AN: 248921995 References: <5nrq5h$13cm@info4.rus.uni-stuttgart.de> <5o39sm$2fl6@info4.rus.uni-stuttgart.de> Organization: PSI Public Usenet Link Newsgroups: comp.lang.ada Date: 1997-06-16T00:00:00+00:00 List-Id: [quotations reformatted for line length] Robert Dewar wrote: > > Michael said > > < 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