From: murphy@mips.COM (Mike Murphy)
Subject: Re: C Strings in Ada?
Date: 12 Jun 90 18:11:07 GMT [thread overview]
Message-ID: <39330@mips.mips.COM> (raw)
In-Reply-To: 920026@hpclapd.HP.COM
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
next prev parent reply other threads:[~1990-06-12 18:11 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
1990-06-04 22:45 C Strings in Ada? Andy DeFaria
1990-06-07 17:41 ` stt
1990-06-08 16:00 ` Andy DeFaria
1990-06-10 20:38 ` Alex Blakemore
1990-06-11 12:57 ` Allan Doyle
1990-06-11 14:59 ` David Kassover
1990-06-11 19:48 ` Allan Doyle
1990-06-11 21:01 ` David Kassover
1990-06-11 22:30 ` Mike Murphy
1990-06-13 21:20 ` Edward Falis
1990-06-11 17:53 ` David Emery
1990-06-11 19:59 ` Allan Doyle
1990-06-15 7:53 ` Jeff Bartlett
1990-06-11 22:39 ` Andy DeFaria
1990-06-12 14:04 ` David Emery
1990-06-12 18:11 ` Mike Murphy [this message]
1990-06-13 13:43 ` stt
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox