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=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: border1.nntp.ams3.giganews.com!border2.nntp.ams3.giganews.com!border2.nntp.ams2.giganews.com!border4.nntp.ams.giganews.com!border2.nntp.ams.giganews.com!nntp.giganews.com!news.unit0.net!news.netfront.net!not-for-mail From: Tarek Ghaleb Newsgroups: comp.lang.ada Subject: Re: System.Address to Access to function/procedure conversion Date: Sun, 28 Jul 2013 22:54:27 +0000 (UTC) Organization: Netfront http://www.netfront.net/ Message-ID: References: <15i0rfwzpj7cy$.ob5l4ffr5iqa$.dlg@40tude.net> <559b2a61-4e5e-4adf-a228-30506d255b08@googlegroups.com> NNTP-Posting-Host: 77.247.181.164 X-Trace: adenine.netfront.net 1375052067 64906 77.247.181.164 (28 Jul 2013 22:54:27 GMT) X-Complaints-To: news@netfront.net NNTP-Posting-Date: Sun, 28 Jul 2013 22:54:27 +0000 (UTC) User-Agent: slrn/1.0.1 (Linux) X-Original-Bytes: 2134 Xref: number.nntp.dca.giganews.com comp.lang.ada:182753 Date: 2013-07-28T22:54:27+00:00 List-Id: On 2013-07-28, Shark8 wrote: >> I agree completely. Using C convention is the way to do it. But is it >> *possible* to call a function using its address? (even if not a such a >> great idea) > Yes. It's actually absurdly easy. Here's a sample of how to do it in > Ada 2012, the same will work in earliet versions of Ada using > Pargmas... all the way back to 83, IIUC. > ACTUAL_TEST: > declare > > Procedure K with Convention => C; > Procedure K is > begin > Ada.Text_IO.Put_Line( "K was called" ); > end K; > > Procedure Execute( Addr : System.Address ) is > Procedure Stub with Import, Convention => C, Address => Addr; > Begin > Stub; > End Execute; > > begin > Execute( K'Address ); > end ACTUAL_TEST; Great! I didn't know about the Address Aspect. I don't think it exists in pragma form, though. At least I couldn't find it in the RM; but thanks, that answers my question. Tarek. -- Aim for the moon. If you miss, you may hit a star. -- W. Clement Stone --- news://freenews.netfront.net/ - complaints: news@netfront.net ---