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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,f4e7d286a074ed9,start X-Google-Attributes: gid103376,public From: Wendell P Beckwith Subject: Help with ADA and C function pointers. Date: 1996/11/20 Message-ID: <32937F73.65A8@rsa.hisd.harris.com>#1/1 X-Deja-AN: 197718407 content-type: text/plain; charset=us-ascii organization: Harris Electronic System Sector mime-version: 1.0 newsgroups: comp.lang.ada x-mailer: Mozilla 2.01 (X11; I; SunOS 5.4 sun4m) Date: 1996-11-20T00:00:00+00:00 List-Id: 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; Procedure Stuff(f : in func_type); pragma Import(C, Stuff, "stuff"); Begin Stuff(funcptr); End; -- my test C function using the ada callback #include void stuff(int (*function)(int)) { printf("Value = %d\n", (*function)(10)); }