From: "Jeffrey L. Susanj" <jeffrey.l.susanj@boeing.com>
Subject: Re: How to convert record?
Date: Thu, 25 Oct 2001 17:12:22 GMT
Date: 2001-10-25T17:12:22+00:00 [thread overview]
Message-ID: <GLruqr.FxD@news.boeing.com> (raw)
In-Reply-To: mailman.1004013820.8836.comp.lang.ada@ada.eu.org
There is no guarantee about the actual layout of a record, particularly
between compilers. I would add a representation clause to fix the layout of
the data.
Jeff S.
"sk" <noname@myob.com> wrote in message
news:mailman.1004013820.8836.comp.lang.ada@ada.eu.org...
> --Anyhow I tried to do Unchecked_Conversion and gnat gave me error
> --message:
> --
> --"unchecked conversion to unconstrained array not allowed".
> --
> --What should I do?
>
> Constrain it
>
> o o
> |
> \_/
>
> declare
>
> type X_Type is record
> a : Natural;
> b : Boolean;
> end record;
>
> Record_Character_Size : Natural := (
> X_Type'Size / Character'Size
> );
>
> type Buffer_Type is new String;
> -- Unconstrained Buffer_Type
>
> subtype String_For_Record is
> Buffer_Type (1 .. Record_Character_Size);
>
> function To_Buffer is new Ada.Unchecked_Conversion (
> Source => X_Type, String_For_Record
> );
>
> X : X_Type;
>
> begin
> Do_Something (To_Buffer(X));
>
> end;
next prev parent reply other threads:[~2001-10-25 17:12 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-10-21 9:56 How to convert record? Joseph Kwan
2001-10-22 11:30 ` John McCabe
2001-10-25 11:40 ` Joseph Kwan
2001-10-25 12:38 ` sk
2001-10-25 17:12 ` Jeffrey L. Susanj [this message]
2001-10-25 12:48 ` David C. Hoos
2001-10-29 1:42 ` Joseph Kwan
2001-10-29 13:35 ` Marc A. Criley
2001-10-25 12:48 ` Marc A. Criley
2001-10-25 12:54 ` sk
2001-10-25 15:41 ` Ted Dennison
2001-10-26 3:21 ` Smark
2001-10-26 5:45 ` James Rogers
2001-10-26 17:46 ` Smark
2001-10-26 14:30 ` Ted Dennison
2001-10-26 17:42 ` Smark
2001-10-26 20:02 ` Ted Dennison
2001-10-26 23:10 ` Jeffrey Carter
-- strict thread matches above, loose matches on Subject: below --
2001-10-29 18:16 Beard, Frank
2001-10-30 1:17 ` Adrian Hoe
2001-10-30 19:05 Beard, Frank
2001-10-31 4:10 ` Adrian Hoe
2001-10-31 19:40 Beard, Frank
2001-11-01 2:13 ` Adrian Hoe
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox