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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,701cccda09aefd03 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!z8g2000prd.googlegroups.com!not-for-mail From: sjw Newsgroups: comp.lang.ada Subject: Re: ada import c function Date: Tue, 28 Apr 2009 14:40:51 -0700 (PDT) Organization: http://groups.google.com Message-ID: <8e93ef24-fe80-4098-9b41-bd8a4adfd8d2@z8g2000prd.googlegroups.com> References: <6568256f-39cd-4757-a630-fe6e4a9a82fc@l16g2000pra.googlegroups.com> NNTP-Posting-Host: 82.20.239.89 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1241047128 2285 127.0.0.1 (29 Apr 2009 23:18:48 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 29 Apr 2009 23:18:48 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: z8g2000prd.googlegroups.com; posting-host=82.20.239.89; posting-account=_RXWmAoAAADQS3ojtLFDmTNJCT0N2R4U User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_6; en-us) AppleWebKit/525.27.1 (KHTML, like Gecko) Version/3.2.1 Safari/525.27.1,gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:5615 Date: 2009-04-28T14:40:51-07:00 List-Id: On Apr 28, 9:45=A0pm, "s. ashen" wrote: > Does anyone import C function to ada?? > Using gnat 3.15, i try to compile the example which contain two files > =A0 use_of_import.adb > > procedure Use_Of_Import is > =A0 =A0procedure Imported_Function; > =A0 =A0pragma Import (C, Imported_Function, "imported_function"); > begin > =A0 =A0Imported_Function; > end Use_Of_Import; > > =A0 imported_function.c > > #include > imported_function () > { > =A0 printf ("\nI am now in the imported function\n\n"); > > } > > does anyone know how to compile this program, i had tried many in many > ways, but i can't do this.. always occurred some =A0errors. nidhoggr:tmp simon$ gcc -c imported_function.c nidhoggr:tmp simon$ gnatmake use_of_import.adb -largs imported_function.o gcc -c use_of_import.adb gnatbind -x use_of_import.ali gnatlink use_of_import.ali imported_function.o nidhoggr:tmp simon$ ./use_of_import I am now in the imported function nidhoggr:tmp simon$ There are ways of doing this with GNAT project files but they would take a while to explain -- and anyway I don't think 3.15 has GNAT project? or if it does it's the first version ever. Upgrade if you can.