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-Thread: a07f3367d7,fa8a8653458b3e4b X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news1.google.com!npeer01.iad.highwinds-media.com!feed-me.highwinds-media.com!cyclone01.ams2.highwinds-media.com!news.highwinds-media.com!npeersf02.ams.highwinds-media.com!newsfe15.ams2.POSTED!40385e62!not-for-mail From: Per Sandberg User-Agent: Thunderbird 2.0.0.22 (Windows/20090605) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: using the 'use at' feature inside a record? References: <8f6142f2-ea37-46d7-a29c-0498da5dd9da@t13g2000yqn.googlegroups.com> In-Reply-To: <8f6142f2-ea37-46d7-a29c-0498da5dd9da@t13g2000yqn.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <%c%pm.68767$Ne3.5147@newsfe15.ams2> X-Complaints-To: abuse@WWWSpace.NET NNTP-Posting-Date: Thu, 10 Sep 2009 04:25:31 UTC Date: Thu, 10 Sep 2009 05:17:33 +0200 Xref: g2news2.google.com comp.lang.ada:8266 Date: 2009-09-10T05:17:33+02:00 List-Id: Well there are always unchecked unions: "ARM B.3.3 Pragma Unchecked_Union" --------------------------- type foo (dummy : Integer := 0) is record case dummy is when 1 => as_integer : integer; when 2 => as_float : Short_Float; when 3 => as_String : String (1 .. 4); when others => as_Stream_Element_Array : Ada.Streams.Stream_Element_Array (1 .. 4); end case; end record; pragma unchecked_Union(foo); --------------------------- The above construct will is an exact equivalent of C's unions. /Per PForan wrote: > Hi all, > > I have a question about the "use at" feature and how it can be used > inside a record to simulate C's unions. I often have an array of > bytes, as well as a string which is "use at"'ed on top of the byte > buffer, very useful as I can play with the data in any way I choose. > i.e. > > byte_buf: array(1..100) of unsigned_8; > str_buf: string(1..100); > for str_buf use at byte_buf'address; > > Is it possible to have something like this within a record? > > TIA, > Phil