Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site watmath.UUCP Path: utzoo!watmath!kpmartin From: kpmartin@watmath.UUCP (Kevin Martin) Newsgroups: net.lang.c Subject: A comment on aggregate constants Message-ID: <9649@watmath.UUCP> Date: Wed, 31-Oct-84 13:51:18 EST Article-I.D.: watmath.9649 Posted: Wed Oct 31 13:51:18 1984 Date-Received: Thu, 1-Nov-84 03:29:26 EST Organization: U of Waterloo, Ontario Lines: 35 >From mark (mwm@ea.UUCP) > struct gort { > int type ; > union info { > struct gfloat { float gfx, gfy } ; > struct gint { long gix, giy } ; > string *name ; > } ; > } sample[] = { > {T_FLOAT, (struct glfoat) { 3.4, 5.7 } } , > {T_INT, (struct gint) { 243, 56 } } , > {T_STRING, (char *) "this is a test" } > } ; >Comments? Although I think that aggregate constants are a nice thing in themselves, I still don't like the name-the-type approach to initualizing unions. I prefer: struct gort { int type ; union info { struct gfloat { float gfx, gfy } gfl; struct gint { long gix, giy } gin; string *name ; } ; } sample[] = { {T_FLOAT, gfl = { 3.4, 5.7 } } , {T_INT, gin = { 243, 56 } } , {T_STRING, name = "this is a test" } } ; I believe that most C compilers now require you to give names to s/u elements even if they are themselves s/u elements, so the first two union elements are improperly declared in the first example. Kevin Martin, UofW Software Development Group