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 X-Google-Thread: 103376,e940dc253695e939 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!feeder.erje.net!news.motzarella.org!motzarella.org!not-for-mail From: =?ISO-8859-1?Q?S=E9bastien?= Newsgroups: comp.lang.ada Subject: Re: Pointer Date: Mon, 19 May 2008 11:31:57 +0000 Organization: A noiseless patient Spider Message-ID: <4831652D.3020507@gmail.com> References: <2rjq6ys3fang$.1ir8q3892mjwo$.dlg@40tude.net> <483152DC.4040607@gmail.com> <93f38d4d-b34f-4858-a818-7dc5d65cbb0b@m36g2000hse.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: feeder.motzarella.org U2FsdGVkX1/l/4JYOoT2g6Vho5Qyuk2TqsyLs7TtQk6YQXOwtn+IN5ik2M+O5cguipIYwstpqd5HJ0OU39bTIDKG8eGhaNYzbjJ/yHZLi8EvXZFQ5qU+UulzOXbVtp3qJdpKOqjcHi9C0VUsIMRrcQ== X-Complaints-To: Please send complaints to abuse@motzarella.org with full headers NNTP-Posting-Date: Mon, 19 May 2008 11:30:01 +0000 (UTC) In-Reply-To: X-Auth-Sender: U2FsdGVkX1+0wKvnxKOUm08vZ91GUWRoseSuRQrVV2zLOGC76CzbJA== Cancel-Lock: sha1:Hh9ZL1oGR9Ozl+NFQUJruN3JYGE= User-Agent: Thunderbird 2.0.0.14 (Windows/20080421) Xref: g2news1.google.com comp.lang.ada:235 Date: 2008-05-19T11:31:57+00:00 List-Id: > procedure To_String (Pointer : in System.Address; Length : in Natural) > return String is > Result : String (1 .. Length); > for Result'Address use Pointer; > pragma Import (Ada, Result); -- suppress default initialization > begin > return Result; > end To_String; > > But Dmitryi's solution is safer, of course. HTH Ok, I was not clear enough. Converting char* to String is not an issue, I'm using Interfaces.C.String with no problem. My problem is to convert all the strings in the char** in string one by one. Something like this: CharPtrPtr: System.Address := MyCFunctionReturninCharStarStar; N: Natural := MYCFunctionTellingMeHowManyStrings; for i in Natural range 0 .. N loop -- Some ada code to convert CharPtrPtr[i] to String end loop; Of course I can do somthing like that: Compile this using gcc -O2 -g3 -ansi -pedantic -W -Wall -c mybind.c -o mybind.o: char* get_nth(char** data, unsigned int n) { return data[i]; } Ada binding: function get_nth(data: System.Address; n: Int) return Char_Ptr; pragma Import(C, get_nth, "get_nth"); Then: for i in Natural range 0 .. N loop MyString := Interfaces.C.Strings.Value(get_nth(CharPtrPtr, i)); end loop; I know it's working, but I have to code a C function in order to do that, is there a way to replace get_nth by an ada code function? Hope it's a better explanation ;-)