Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 5 Aug 1998 01:03:14 +0000 (GMT)
From:      Terry Lambert <tlambert@primenet.com>
To:        chuckr@glue.umd.edu (Chuck Robey)
Cc:        Nicolas.Souchu@prism.uvsq.fr, freebsd-hackers@FreeBSD.ORG
Subject:   Re: C and static initialization with unions
Message-ID:  <199808050103.SAA27705@usr02.primenet.com>
In-Reply-To: <Pine.BSF.4.00.9808041508210.409-100000@picnic.mat.net> from "Chuck Robey" at Aug 4, 98 03:09:11 pm

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 }
	};


					Terry Lambert
					terry@lambert.org
---
Any opinions in this posting are my own and not those of my present
or previous employers.

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?199808050103.SAA27705>