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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: =?UTF-8?Q?Bj=c3=b6rn_Lundin?= Newsgroups: comp.lang.ada Subject: Re: How to bind this properly, C ** which is an array Date: Fri, 1 Mar 2019 14:54:29 +0100 Organization: A noiseless patient Spider Message-ID: References: <1bb2318a-eb48-450f-908d-a304b92bd74c@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Date: Fri, 1 Mar 2019 13:54:31 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="a169a42440eacaa7054d6e86ffbce0de"; logging-data="4703"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+RPELK1HPPLXpWQQB1/3Kh" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 Cancel-Lock: sha1:DQQxNSiDlOk60BB1GcFddGbw0bU= In-Reply-To: <1bb2318a-eb48-450f-908d-a304b92bd74c@googlegroups.com> Content-Language: sv-FI Xref: reader01.eternal-september.org comp.lang.ada:55737 Date: 2019-03-01T14:54:29+01:00 List-Id: On 2019-03-01 14:48, Lucretia wrote: > Hi, > > I'm trying to bind the following struct: > > typedef struct mpc_ast_t { > char *tag; > char *contents; > mpc_state_t state; > int children_num; > struct mpc_ast_t** children; > } mpc_ast_t; > > I have this: > > type ASTs is > record > Tag : C.Strings.chars_ptr; > Contents : C.Strings.chars_ptr; > State : States; > Number_Of_Children : C.int; > Children : System.Address; -- Pointer to a pointer to an array of ASTs. > end record with > Convention => C; > > Children needs to be accessed in code as a pointer to a pointer to an array of ASTs. > > How do I best bind this thing? It's likely going to have to be converted from Address to a particular type using Unchecked_Conversion most likely. > > Thanks, > Luke. > naïvly I would have tried something like type Ptr_To_Chars_Ptr is access all C.Strings.chars_ptr; type ASTs is record Tag : C.Strings.chars_ptr; Contents : C.Strings.chars_ptr; State : States; Number_Of_Children : C.int; Children : Ptr_To_Chars_Ptr; end record with Convention => C; -- -- Björn