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 X-Received: by 2002:a6b:2191:: with SMTP id h139-v6mr17961680ioh.27.1537185701927; Mon, 17 Sep 2018 05:01:41 -0700 (PDT) X-Received: by 2002:a9d:2306:: with SMTP id j6-v6mr182048otb.3.1537185701815; Mon, 17 Sep 2018 05:01:41 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!news.uzoreto.com!weretis.net!feeder6.news.weretis.net!feeder.usenetexpress.com!feeder-in1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!x188-v6no27346ite.0!news-out.google.com!z5-v6ni36ite.0!nntp.google.com!x188-v6no27342ite.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 17 Sep 2018 05:01:41 -0700 (PDT) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=121.45.194.120; posting-account=3BDb0woAAAAxEpy0UNGOioOboBRjpqqT NNTP-Posting-Host: 121.45.194.120 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Interface To C Struct That Includes An Array From: rogermc@iinet.net.au Injection-Date: Mon, 17 Sep 2018 12:01:41 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader02.eternal-september.org comp.lang.ada:54337 Date: 2018-09-17T05:01:41-07:00 List-Id: I'm having problems interfacing the following record to C. type API_String is record Length : Interfaces.C.size_t :=3D 0; Data : API_String_Data_Array :=3D (others =3D> Interfaces.C.char'V= al (0)); end record; pragma Convention (C_Pass_By_Copy, API_String); In general it seems OK, however, the following function in which Assimp_Pat= h'Access is returned=20 from a C function produces a strange result=20 Result :=3D API_Get_Material_Texture (Material'Access, Tex_Type, unsigned = (Tex_Index), Assimp_Path'Access); The returned Assimp_Path is Length: 16, Data: =0BB000phoenix.pcx0000 in which B is a series of four small zeros inside a rectangle. I haven't been able to find a syntactical explanation for the four small ze= ros inside a rectangle. The expected Assimp_Path is Length: 11, Data: phoenix.pcx Memory inspection indicates that the Length 16 includes both the expected l= ength and character string. (gdb) print Assimp_Path $8 =3D (length =3D> 16, data =3D> (0 =3D> 11, 0, 0, 0, 112, 104, 111, 101, = 110, 105, 120, 46, 112, 99, 120, 0 ) If I shift the Data characters left by four places and change Length to 12,= the resultant Assimp_Path is Length: 16, Data: =0BBphoenix.pcx The C interface is: function API_Get_Material_Texture (aMaterial : access API_Material_Te= x; Tex_Type : AI_Texture_Type; Index : Interfaces.C.unsigned; Path : access Assimp_Types.AP= I_String :=3D null; Mapping : access AI_Texture_Mapp= ing :=3D null; UV_Index : access Interfaces.C.un= signed :=3D null; Blend : access Interfaces.C.C_= float :=3D null; Op : access AI_Texture_Op := =3D null; Map_Mode : access AI_Texture_Map_= Mode :=3D null) return Assimp_Types.API_Return; pragma Import (C, API_Get_Material_Texture, "aiGetMaterialTexture"); Any positive advice or explanation will be appreciated. Roger