From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11982 invoked by alias); 24 Mar 2008 08:48:48 -0000 Received: (qmail 11970 invoked by uid 22791); 24 Mar 2008 08:48:47 -0000 X-Spam-Check-By: sourceware.org Received: from sohm.kpitcummins.com (HELO sohm.kpit.com) (203.197.93.231) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 24 Mar 2008 08:48:22 +0000 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: Re: how to initialize union? Date: Mon, 24 Mar 2008 08:48:00 -0000 Message-ID: <78DE440C4156CC45A35FDBCBF9B830D70241D51D@sohm.kpit.com> From: "Deepen Mantri" To: Cc: Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2008-03/txt/msg00236.txt.bz2 >>union my_union { >> struct { >> int a; >> int b; >> }; >> struct { >> char a; >> short b; >> void *c; >> } v; >>}; >>And I want to initialize 2 global variables, of `my_union' type, >>A and B to: >>------------------------------------ >>A.a=3D1; A.b=3D2; >>B.v.a=3D'a'; B.v.b=3D16; B.v.c=3DNULL; >>------------------------------------ >>I know how to initialize A by: >>union my_union A =3D { 1, 2 }; >>But I don't know how to write the initializers for B. >>Can gcc support this feature? The union variable can be initialized with the help of, union my_union B =3D {.v =3D {'a',16,NULL}}; Regards, Deepen Mantri KPIT Cummins InfoSystems Ltd. Pune, India ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Free download of GNU based tool-chains for Renesas' SH, H8, R8C, M16C and M32C Series. The following site also offers free technical support to its users. Visit http://www.kpitgnutools.com for details. Latest versions of KPIT GNU tools were released on February 4, 2008 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~