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=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.236.11.194 with SMTP id 42mr8370238yhx.19.1413594253399; Fri, 17 Oct 2014 18:04:13 -0700 (PDT) X-Received: by 10.182.22.13 with SMTP id z13mr62960obe.5.1413594253266; Fri, 17 Oct 2014 18:04:13 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.stack.nl!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!peer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!s7no3513335qap.0!news-out.google.com!rp1ni32382igb.0!nntp.google.com!uq10no12809718igb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 17 Oct 2014 18:04:13 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=149.32.224.35; posting-account=Qh2kiQoAAADpCLlhT_KTYoGO8dU3n4I6 NNTP-Posting-Host: 149.32.224.35 References: <7dec5a01-4376-4f86-b4f3-b28948474828@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <4ae8855e-8999-41bd-946d-a7ba8658ad4e@googlegroups.com> Subject: Re: Interface with C codes From: Anh Vo Injection-Date: Sat, 18 Oct 2014 01:04:13 +0000 Content-Type: text/plain; charset=ISO-8859-1 X-Received-Bytes: 2722 X-Received-Body-CRC: 364691058 Xref: news.eternal-september.org comp.lang.ada:22561 Date: 2014-10-17T18:04:13-07:00 List-Id: On Friday, October 17, 2014 5:04:17 PM UTC-7, Anh Vo wrote: > On Friday, October 17, 2014 4:49:04 PM UTC-7, Adam Beneschan wrote: > > > On Friday, October 17, 2014 4:22:15 PM UTC-7, Anh Vo wrote: > > > > > What Ada spec should be for the following C prototype where BOOT_PARAMS is a struct and responding Ada type is > > > > type Boot_Parameter_Type is > > > record > > > Boot_Dev : Interfaces.C.Strings.Chars_Ptr; > > > -- ... > > > end record; > > > pragma Convention (C, Boot_Parameter_Type); > > > > > type Boot_Parameter_Type_Access is access Boot_Parameter_Type; > > > pragma Convention (C, Boot_Parameter_Type_Access); > > > > > typedef struct /* BOOT_PARAMS */ > > > { > > > char bootDev [20]; /* boot device code */ > > > * ... * > > > } BOOT_PARAMS; > > > > > Note that I can not use Ada 2012 yet. > > > > > char * bootStringToStruct (char * bootString, BOOT_PARAMS * pBootParams); > > > > I'm confused. You've defined an Ada record Boot_Parameter_Type that has a pointer in it, and a C struct that does not have a pointer. > > > > The second parameter of the function prototype use pointer, BOOT_PARAMS * pBootParams. > How this one. function Boot_String_To_Type ( Boot_String : Interfaces.C.Strings.chars_ptr; Boot_Params : System.Address) return Interfaces.C.Strings.chars_ptr; pragma Import (C, Boot_String_To_Type, "bootStringToStruct");