From owner-freebsd-hackers Tue Aug 4 18:03:30 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id SAA03701 for freebsd-hackers-outgoing; Tue, 4 Aug 1998 18:03:30 -0700 (PDT) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from smtp04.primenet.com (smtp04.primenet.com [206.165.6.134]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id SAA03695 for ; Tue, 4 Aug 1998 18:03:29 -0700 (PDT) (envelope-from tlambert@usr02.primenet.com) Received: (from daemon@localhost) by smtp04.primenet.com (8.8.8/8.8.8) id SAA20773; Tue, 4 Aug 1998 18:03:18 -0700 (MST) Received: from usr02.primenet.com(206.165.6.202) via SMTP by smtp04.primenet.com, id smtpd020736; Tue Aug 4 18:03:16 1998 Received: (from tlambert@localhost) by usr02.primenet.com (8.8.5/8.8.5) id SAA27705; Tue, 4 Aug 1998 18:03:14 -0700 (MST) From: Terry Lambert Message-Id: <199808050103.SAA27705@usr02.primenet.com> Subject: Re: C and static initialization with unions To: chuckr@glue.umd.edu (Chuck Robey) Date: Wed, 5 Aug 1998 01:03:14 +0000 (GMT) Cc: Nicolas.Souchu@prism.uvsq.fr, freebsd-hackers@FreeBSD.ORG In-Reply-To: from "Chuck Robey" at Aug 4, 98 03:09:11 pm X-Mailer: ELM [version 2.4 PL25] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > > 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