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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,69d0258abc166f15,start X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!f14g2000cwb.googlegroups.com!not-for-mail From: "Brian" Newsgroups: comp.lang.ada Subject: GNAT Unchecked_Union and multiple components Date: 18 Apr 2005 07:58:00 -0700 Organization: http://groups.google.com Message-ID: <1113836280.439166.180090@f14g2000cwb.googlegroups.com> NNTP-Posting-Host: 208.20.220.72 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1113836285 14483 127.0.0.1 (18 Apr 2005 14:58:05 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 18 Apr 2005 14:58:05 +0000 (UTC) User-Agent: G2/0.2 Complaints-To: groups-abuse@google.com Injection-Info: f14g2000cwb.googlegroups.com; posting-host=208.20.220.72; posting-account=YwIosQ0AAAAoDcE7AKA726BVRd2vd_jK Xref: g2news1.google.com comp.lang.ada:10526 Date: 2005-04-18T07:58:00-07:00 List-Id: Hi, I've started to use GNAT 3.15p and noticed it handles the pragma Unchecked_Union differently from other compilers. According to the GNAT Reference Manual "Each variant has a component list with a single component.", if you violate this rule the compiler will generate the error "Unchecked_Union variant can have only one component". Other compilers allow multiple components per variant. Is there a GNAT compiler switch I can use to loosen this restriction? My current workaround is to create a new record type containing the multiple components and use it as the type for one of the variants (see code snippet below). Thanks. Regards, Brian type Msg_Type is (Msg_A, Msg_B); -- This is what I want as my variant record type definition. type Data_Type1(Msg : Msg_Type := Msg_A) is record case Msg is when Msg_A => A1 : Integer; A2 : Integer; when Msg_B => B : Float; end case; end record; -- This is my current workaround. type Msg_A_Variant is record A1 : Integer; A2 : Integer; end record; type Data_Type1(Msg : Msg_Type := Msg_A) is record case Msg is when Msg_A => A : Msg_A_Variant; when Msg_B => B : Float; end case; end record; -- end workaround pragma Unchecked_Union(Data_Type1);