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.3 required=5.0 tests=BAYES_00,INVALID_MSGID,XPRIO autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,cc7bad83fb245cb3 X-Google-Attributes: gid103376,public From: Tom_Hargraves@Raytheon.com Subject: Re: Binding a type to a union. Date: 1999/11/23 Message-ID: #1/1 X-Deja-AN: 552136607 X-MIMETrack: Serialize by Router on RESMAIL70/SRV/Raytheon/CA(Release 5.0.1b|September 30, 1999) at 11/23/1999 09: 42:55 AM To: comp.lang.ada@ada.eu.org X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@enst.fr X-Trace: menuisier.enst.fr 943379017 17910 137.194.161.2 (23 Nov 1999 17:43:37 GMT) Organization: ENST, France X-BeenThere: comp.lang.ada@ada.eu.org Mime-Version: 1.0 Reply-To: comp.lang.ada@ada.eu.org NNTP-Posting-Date: 23 Nov 1999 17:43:37 GMT Newsgroups: comp.lang.ada Date: 1999-11-23T17:43:37+00:00 List-Id: Thanks for the example of pragma Unchecked_Union in your reply. I have learnt another pragma today :-) However, wouldn't its use be restricted to when the type was to be used in a 'C' language interface call? The pragma comes with a long list of restrictions which perhaps, generally, would be undesirable. Yours curiously, Tom H. "David Botton" on 11/22/99 07:55:33 PM Please respond to comp.lang.ada@ada.eu.org From:"David Botton" on 11/22/99 07:55 PM To: comp.lang.ada@ada.eu.org cc: (bcc: Tom Hargraves/RMD/Raytheon/CA) Subject: Re: Binding a type to a union. You would do the following: type foo_struct is record x : C.Int; end record; type bar_struct is record x : C.char; y : some_enum_type; end record; subtype Union_1_Range is Positive range 1..2; type Union_1 (Which : Union_1_Range) is record case Which is when 1 => foo : foo_struct; when 2 => bar : bar_struct; end record; pragma Unchecked_Union(Union_1); type foo_type is record foo_bar : Union_1; end record; Then you can access using: my : foo_type; my.foo_bar.foo.x := 1; etc. David Botton Aidan Skinner wrote in message ... >Can anybody tell me the correct way to give an Ada representation of a >C union contained in a structure? > >Eg given a declaration in C of: > >struct foo > { > > union > { > struct > { > int x; > } foo > > struct > { > char x; > some_enum_type y; > } bar > > } foo_bar > } > >What's the correct way of doing this given that x needs to be >public? > >- Aidan _______________________________________________ comp.lang.ada mailing list comp.lang.ada@ada.eu.org http://ada.eu.org/cgi-bin/mailman/listinfo/comp.lang.ada