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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,a7d2d00671375b58 X-Google-Attributes: gid103376,public From: nasser@paralysys (Nasser Abbasi) Subject: Re: GNAT Strings Date: 1996/04/21 Message-ID: #1/1 X-Deja-AN: 150608329 sender: news@biosys.apldbio.COM references: <4l0oiq$4e8@arl-news-svc-2.compuserve.com> to: 100331.2264@compuserve.com (R.J. Kirkbride) organization: Applied BioSystems newsgroups: comp.lang.ada Date: 1996-04-21T00:00:00+00:00 List-Id: In article <4l0oiq$4e8@arl-news-svc-2.compuserve.com> 100331.2264@compuserve.com (R.J. Kirkbride) writes: Does anyone know how strings are stored in GNAT, and thus how they can be sent from C. I think a pointer is first sent to the string and then a pointer to a structure containing first and last pointers but I am not absolutely sure this is correct. Any help would be much appreciated, Rob. for unbounded string is, a-strunb.ads shows it is a pointer, opps, I mean access to a string: >private > package AF renames Ada.Finalization; > > type Unbounded_String is new AF.Controlled with record > Reference : String_Access; > end record; for bounded string , a-strbou.ads shows it is a record with length field, and the data itself field, where length indicates current length: > private > > type Bounded_String is record > Length : Length_Range := 0; > Data : String (1 .. Max_Length); > end record; The length of unbounded string is then found like this: from a-strunb.adb: function Length (Source : Unbounded_String) return Natural is begin return Source.Reference.all'Length; end Length; The length of the bounded string is in the record itself shown above. so from a-strbou.adb: function Length (Source : in Bounded_String) return Length_Range is begin return Source.Length; end Length; String itself offcourse is array of characters. to interface to C, there is a package for that (interfaces package) one of its children is C.Interface . Nasser