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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,34e28efa1a88ae84 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!newsfeed.straub-nv.de!news.motzarella.org!motzarella.org!not-for-mail From: =?ISO-8859-1?Q?S=E9bastien?= Newsgroups: comp.lang.ada Subject: Re: Access procedure to pointer Date: Wed, 28 May 2008 09:06:37 +0000 Organization: A noiseless patient Spider Message-ID: <483D209D.5010408@gmail.com> References: <483C48B5.9060303@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: feeder.motzarella.org U2FsdGVkX19OKN7nku63JkwW3HOxhqLufc8OyXxXL8Eyyks8hLJ5TdLAdYsOazglA0UKOGj+aN5xPQI4ft7pym1gk3KYY3+NA7tgntInyKSsEacUgYWndocsqxll5qeKL076sf7blF5IcUARd94jzA== X-Complaints-To: Please send complaints to abuse@motzarella.org with full headers NNTP-Posting-Date: Wed, 28 May 2008 09:06:45 +0000 (UTC) In-Reply-To: X-Auth-Sender: U2FsdGVkX189J1AsEgGB8lOurKN7PIQXWQy7l+bjPnWCQj+YcrRiOg== Cancel-Lock: sha1:x2GimYYcOAhO60cfEf7oaQdEGWg= User-Agent: Thunderbird 2.0.0.14 (Windows/20080421) Xref: g2news1.google.com comp.lang.ada:415 Date: 2008-05-28T09:06:37+00:00 List-Id: > I would suggest a cleaner: > > type Callback is access procedure; > pragma Convention (C, Callback); > > procedure Foo; > pragma Convention (C, Foo); > > Ptr : constant Callback := Foo'Access; > > Callback is an equivalent to C pointer to a function. The point was I'm not using constant. My code looks like this: type Signal is (SIGHUP); for Signal use (SIGHUP => 1); type Signal_Callback is access procedure(sig: Signal); procedure InterceptSignal(sig: in Signal; callback: in Signal_Callback); procedure c_signal(sig: in Signal; callback: in System.Address); pragma Import(C, c_signal, "signal"); procedure HelloFromSignal(sig: Signal) is begin Put_Line("Hello from" & Signal'Image(sig)); end HelloFromSignal; procedure Main is begin InterceptSignal(SIGUP, HelloFromSignal'Access); delay 30; end Main; So I change the code following your instruction : procedure c_signal(sig: in Signal; callback: in Signal_Callback); And did add all the pragma Contention where you told me. It works fine and looks like more portable ;-) Thanks for all your answers and help. Moreover, I discover that sigaction and other Signal function are implemented in Gnat 4.3 in the System.OS_Interface. Even if "signal" itself is missing, there is some ways to do it without any C interface in my code. Really documentation is missing about what is available in GNAT and examples, too bad! Sebastien