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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,79db4ff72bff9422 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-10-25 10:52:47 PST Newsgroups: comp.lang.ada Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.uchicago.edu!newsfeed.cs.wisc.edu!newsfeed.mathworks.com!news.mathworks.com!uunet!nyc.uu.net!ash.uu.net!xyzzy!nntp From: "Jeffrey L. Susanj" Subject: Re: How to convert record? X-Nntp-Posting-Host: p2005079.mw.nos.boeing.com Message-ID: X-Mimeole: Produced By Microsoft MimeOLE V5.50.4133.2400 X-Priority: 3 X-Msmail-Priority: Normal Sender: nntp@news.boeing.com (Boeing NNTP News Access) Organization: The Boeing Company X-Newsreader: Microsoft Outlook Express 5.50.4133.2400 References: <80d2e34.0110210156.7918cd3d@posting.google.com> <3bd402f9.8783319@news.demon.co.uk> <80d2e34.0110250340.155ae0b7@posting.google.com> Date: Thu, 25 Oct 2001 17:12:22 GMT Xref: archiver1.google.com comp.lang.ada:15191 Date: 2001-10-25T17:12:22+00:00 List-Id: 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" 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;