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.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,f4e7d286a074ed9 X-Google-Attributes: gid103376,public From: fd@piau () Subject: Re: Help with ADA and C function pointers. Date: 1996/11/26 Message-ID: <57eigc$6ce@news.cict.fr>#1/1 X-Deja-AN: 200829765 references: <32937F73.65A8@rsa.hisd.harris.com> organization: DULUC Franck at Aerospatiale Toulouse reply-to: franck.duluc@avions.aerospatiale.fr newsgroups: comp.lang.ada Date: 1996-11-26T00:00:00+00:00 List-Id: Wendell P Beckwith (wbeckwit@rsa.hisd.harris.com) wrote: : I have an ada main procedure which needs to pass the address of an ada : function to a C funciton. Using gnat 3.05 the following compiles and : generates an executable, but it cores when you run it. I knew it would : because no where am I assigning a function to be passed. That is what : I'd like to know how to do. Please respond to my work email, since I'm : not in this group alot. Thanks!! : Wendell : -- my test main : with Text_IO, Interfaces.C; : use Text_IO; : Procedure Gmain is : Function func(d : in Integer) return Integer is : Begin : return (2 * d); : End; : type func_type is access Function(d : in Integer) return Integer; : funcptr : func_type; Here funcptr value is NULL : : Procedure Stuff(f : in func_type); : pragma Import(C, Stuff, "stuff"); : : Begin : Stuff(funcptr); there is a problem, funcptr is still equal to NULL I will try Stuff(func'adress) and you don't need funcptr. Hope it will help. : End; : -- my test C function using the ada callback : #include : void stuff(int (*function)(int)) : { : printf("Value = %d\n", (*function)(10)); : } franck.duluc@avions.aerospatiale.fr Regards.