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 2002:a02:3d4e:: with SMTP id n75-v6mr21460833jan.51.1537225592092; Mon, 17 Sep 2018 16:06:32 -0700 (PDT) X-Received: by 2002:a9d:4c8d:: with SMTP id m13-v6mr204737otf.6.1537225592002; Mon, 17 Sep 2018 16:06:32 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!feeder3.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!feeder-in1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!x188-v6no10534ite.0!news-out.google.com!z5-v6ni13ite.0!nntp.google.com!x81-v6no10716ita.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 17 Sep 2018 16:06:31 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=121.45.194.120; posting-account=d51RWwoAAADvR-x0zYAtT9z3CRxT1eXo NNTP-Posting-Host: 121.45.194.120 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <7aec23ef-91ab-4048-b530-02294d31a2f1@googlegroups.com> Subject: Re: Interface To C Struct That Includes An Array From: Roger Injection-Date: Mon, 17 Sep 2018 23:06:32 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader02.eternal-september.org comp.lang.ada:54352 Date: 2018-09-17T16:06:31-07:00 List-Id: On Tuesday, September 18, 2018 at 1:24:09 AM UTC+10, Lucretia wrote: > On Monday, 17 September 2018 13:01:43 UTC+1, rog...@iinet.net.au wrote: > > I'm having problems interfacing the following record to C. > > > > type API_String is record > > Length : Interfaces.C.size_t := 0; > > Data : API_String_Data_Array := (others => Interfaces.C.char'Val (0)); > > end record; > > pragma Convention (C_Pass_By_Copy, API_String); > > Variable length things in Ada are problematic no matter what really. > > What does the type definition of API_String_Data_Array look like? Is it also Convention => C? I've replaced API_String_Data_Array with its original declaration which was subtype API_String_Data_Array is char_array (0 .. Max_Length - 1):= (others => Interfaces.C.char'Val (0)); -- This declaration has been checked OK for Key data. DON'T CHANGE type API_String is record Length : Interfaces.C.size_t := 0; Data : char_array (0 .. Max_Length - 1):= (others => Interfaces.C.char'Val (0)); end record; pragma Convention (C_Pass_By_Copy, API_String); but the same problem remains