Date: Tue, 04 Aug 1998 18:49:27 -0700 From: Mike Smith <mike@smith.net.au> To: Terry Lambert <tlambert@primenet.com> Cc: chuckr@glue.umd.edu (Chuck Robey), Nicolas.Souchu@prism.uvsq.fr, freebsd-hackers@FreeBSD.ORG Subject: Re: C and static initialization with unions Message-ID: <199808050149.SAA01073@dingo.cdrom.com> In-Reply-To: Your message of "Wed, 05 Aug 1998 01:03:14 -0000." <199808050103.SAA27705@usr02.primenet.com>
next in thread | previous in thread | raw e-mail | index | archive | help
> > > union foo_t { > > > int i; > > > char c; > > > void *p; > > > }; > > > > > > static union foo_t bar = { (void *)&anyvar }; > > > > No, you forgot to mention which union memeber to use. Your foo_t.p > > would do nicely. > > 1) This is a vendor extension. > > 2) That vendor isn't FSF or Cygnus. > > 3) It's "foo_t bar.p", not "foo_t.p bar". > > 4) It still breaks for: > > typedef enum { UT_INT, UT_CHAR, UT_PTR } ut_t; > > typedef struct { > ut_t u_type; > struct foo_t u; /* someone blew a typedef*/ > } bob_t; > > bob_t bobs.p[] = { > { UT_PTR, &anyvar }, > { UT_INT, 35 }, /* oops!*/ > { UT_PTR, NULL } > }; > The gcc info "extensions/named elements" section describes a useful extension that lets you cut through much of this crap. -- \\ Sometimes you're ahead, \\ Mike Smith \\ sometimes you're behind. \\ mike@smith.net.au \\ The race is long, and in the \\ msmith@freebsd.org \\ end it's only with yourself. \\ msmith@cdrom.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199808050149.SAA01073>