From owner-freebsd-hackers Tue Aug 4 17:19:34 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id RAA24585 for freebsd-hackers-outgoing; Tue, 4 Aug 1998 17:19:34 -0700 (PDT) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from artemis.syncom.net (artemis.syncom.net [206.64.31.2]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id RAA24559 for ; Tue, 4 Aug 1998 17:19:29 -0700 (PDT) (envelope-from cyouse@artemis.syncom.net) Received: from localhost (localhost [[UNIX: localhost]]) by artemis.syncom.net (8.8.8/8.8.8) with SMTP id UAA17176; Tue, 4 Aug 1998 20:29:49 -0400 (EDT) Date: Tue, 4 Aug 1998 20:29:49 -0400 (EDT) From: Charles Youse To: Nicolas Souchu cc: FreeBSD Hackers Subject: Re: C and static initialization with unions In-Reply-To: <19980804185938.36803@breizh.prism.uvsq.fr> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Tue, 4 Aug 1998, Nicolas Souchu wrote: > union foo_t { > int i; > char c; > void *p; > }; > > static union foo_t bar = { (void *)&anyvar }; If you wish to initialize these unions using void pointers, then the void pointer element comes first. Otherwise, you're stuck using casts, which aren't necessarily safe. C dictates that union initializations take the form of the first member of the union. Chuck To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message