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 autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,cc7bad83fb245cb3,start X-Google-Attributes: gid103376,public From: "David Botton" Subject: Re: Binding a type to a union. Date: 1999/11/22 Message-ID: <81d384$1g8o$1@news.gate.net>#1/1 X-Deja-AN: 551914962 References: X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3612.1700 X-Complaints-To: abuse@gate.net X-Trace: news.gate.net 943329348 49432 199.227.148.191 (23 Nov 1999 03:55:48 GMT) Organization: CyberGate, Inc. NNTP-Posting-Date: 23 Nov 1999 03:55:48 GMT Newsgroups: comp.lang.ada Date: 1999-11-23T03:55:48+00:00 List-Id: 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