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.7 required=5.0 tests=BAYES_00,INVALID_DATE, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!cs.utexas.edu!usc!apple!mips!gumby!murphy From: murphy@mips.COM (Mike Murphy) Newsgroups: comp.lang.ada Subject: Re: C Strings in Ada? Message-ID: <39330@mips.mips.COM> Date: 12 Jun 90 18:11:07 GMT References: <920024@hpclapd.HP.COM> <920026@hpclapd.HP.COM> Sender: news@mips.COM Reply-To: murphy@mips.COM (Mike Murphy) Organization: MIPS Computer Systems, Sunnyvale, CA List-Id: In article <920026@hpclapd.HP.COM> defaria@hpclapd.HP.COM (Andy DeFaria) writes: >Also, no one has address my other concern about how to represent these >strings in structures such as: > >struct data_record { > char *path; > int path_length; > char *name; > int name_length; >} It seems to me that the simple solution is to just define a c_string type which is an access to a constrained string, and then some routines to convert strings to c_strings and vice-versa. Then you define your records to match the C structures: type data_record is record path : c_string; path_length : integer; name : c_string; name_length : integer; end record; The cost of converting strings to c_strings is probably not as bad as you imagine, depending on your application (e.g. chances are you will only convert string to c_string once, then do many calls to C routines with the c_string structures). BTW, Verdix uses such an approach in their UNIX interfaces (there is a c_strings package in the standard library). -- Mike Murphy -- UUCP: sun!decwrl!mips!murphy or murphy@mips.com