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 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Simon Clubley Newsgroups: comp.lang.ada Subject: Re: Interface with C codes Date: Sun, 19 Oct 2014 09:24:16 +0000 (UTC) Organization: A noiseless patient Spider Message-ID: References: <7dec5a01-4376-4f86-b4f3-b28948474828@googlegroups.com> <58556409-4da1-41a2-944b-4cf7aaaf0504@googlegroups.com> <85iojhdy87.fsf@stephe-leake.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Injection-Date: Sun, 19 Oct 2014 09:24:16 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="63a1798279ecc4acca8f41aeced4a116"; logging-data="17782"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18ZRB+FBjBMajaet17aqvPutXUPKLQTqsM=" User-Agent: slrn/0.9.9p1 (Linux) Cancel-Lock: sha1:471l/rAsoxFbKxCHKKBqDN2EhaU= Xref: news.eternal-september.org comp.lang.ada:22583 Date: 2014-10-19T09:24:16+00:00 List-Id: On 2014-10-19, Anh Vo wrote: > On Saturday, October 18, 2014 11:33:32 AM UTC-7, Stephen Leake wrote: >> Anh Vo writes: >> > On Friday, October 17, 2014 4:22:15 PM UTC-7, Anh Vo wrote: >> >> >> >> char * bootStringToStruct (char * bootString, BOOT_PARAMS * pBootParams); >> > >> > Should this one work? >> > >> > function Boot_String_To_Type ( >> > Boot_String : Interfaces.C.Strings.chars_ptr; >> > Boot_Params : Boot_Parameter_Type_Access) >> > return Interfaces.C.Strings.chars_ptr; >> > pragma Import (C, Boot_String_To_Type, "bootStringToStruct"); >> >> Looks good. but give -fdump-ada-spec a try. > > Yes, I tried and the result is below. > > function bootStringToStruct (bootString : Interfaces.C.Strings.chars_ptr; > pBootParams : access BOOT_PARAMS) > return Interfaces.C.Strings.chars_ptr; > pragma Import (CPP, bootStringToStruct, "_Z18bootStringToStructPcP11BOOT_PARAMS"); > > Why was "_Z18bootStringToStructPcP11BOOT_PARAMS" generated for third parameter of pragma Import? I thought it should be "bootStringToStruct". > It's known as a mangled symbol and is required with C++ (notice your latter example is using "CPP" and not "C" on the pragma Import). The "Name mangling in C++" section of the following might be useful: http://en.wikipedia.org/wiki/Name_mangling Simon. -- Simon Clubley, clubley@remove_me.eisner.decus.org-Earth.UFP Microsoft: Bringing you 1980s technology to a 21st century world