comp.lang.ada
 help / color / mirror / Atom feed
From: Roger <rogermcm2@gmail.com>
Subject: Re: Interface To C Struct That Includes An Array
Date: Mon, 17 Sep 2018 16:06:31 -0700 (PDT)
Date: 2018-09-17T16:06:31-07:00	[thread overview]
Message-ID: <7aec23ef-91ab-4048-b530-02294d31a2f1@googlegroups.com> (raw)
In-Reply-To: <a3f03045-061e-4a75-b7e9-ad8a40184d47@googlegroups.com>

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

  reply	other threads:[~2018-09-17 23:06 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-17 12:01 Interface To C Struct That Includes An Array rogermc
2018-09-17 12:11 ` rogermc
2018-09-17 15:25   ` Lucretia
2018-09-17 22:35     ` Roger
2018-09-18  0:45       ` Roger
2018-09-18  1:19         ` rogermc
2018-09-17 12:26 ` gautier_niouzes
2018-09-17 13:28   ` Roger
2018-09-17 13:55     ` gautier_niouzes
2018-09-17 14:03       ` Roger
2018-09-17 15:24 ` Lucretia
2018-09-17 23:06   ` Roger [this message]
2018-09-17 16:29 ` Jeffrey R. Carter
2018-09-17 22:57   ` Roger
2018-09-18  0:53   ` Roger
2018-09-18  4:18     ` Roger
2018-09-18  8:19 ` rakusu_klein
2018-09-18 11:54   ` rogermc
2018-09-18 12:21     ` Egil H H
2018-09-18 12:24       ` rogermc
2018-09-18 18:55     ` rakusu_klein
2018-09-18 21:28       ` rogermc
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox