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,654b6f3511044d16 X-Google-Attributes: gid103376,public From: Andy McNerney Subject: Re: Interfacing Ada Routines in C Date: 1996/09/11 Message-ID: <515ug1$6ne@gcsin3.geccs.gecm.com>#1/1 X-Deja-AN: 180404959 references: <5156mj$gd0@rumors.ucr.edu> <85u3t5wr8q.fsf@walleroo.rp.CSIRO.AU> content-type: text/plain; charset=us-ascii organization: GEC-Marconi S3I mime-version: 1.0 newsgroups: comp.lang.ada x-mailer: Mozilla 1.22 (Windows; I; 16bit) Date: 1996-09-11T00:00:00+00:00 List-Id: Greg Baker wrote: >> Does anyone know how I can interface an Ada procedure in my >> C program? >> I've tried the following unsuccessfully: >> >> Compiled the ada procedure into an object file. Included >> the ada object file during the link, but the compiler isn't >> able to find the procedure referenced in my C program. >> >> BTW, I am using gcc and Sun Ada on a Solaris platform. > >The Ada compiler does some slight name mangling (it includes the name >of the package in the link name). >Without checking too carefully.. > >Ada: > package Foo is > procedure Bar; > end Foo; > >C: > extern void foo__bar(); > This, unfortunately, is an Appendix F issue. The way I have had to do it, using gcc and gnat ADA, on an SGI is to use PRAGMA EXPORT within the ADA, so that the C can see the symbol with the name of your choosing : Eg: function create (bob : in bob_type) return integer; PRAGMA EXPORT (c, create, External_Name => "create"); --------------------------------------------^^^^ This can be what ever you wish to call the routine as seen from the C. Using VERDIX ada, also on SGI the synax is as follows: function create (bob : in bob_type ) return integer; PRAGMA external_name ( create, "create"); This aviods you 'hacking' the C to get it to work. Hope this helps. ------------------------------------------------------------------------- Andrew A McNerney | andy.mcnerney@gecm.com | These are my personal opinions GEC Marconi S3i | and NOT those of my employer. Simulation and Training Division | -------------------------------------------------------------------------