From owner-freebsd-hackers Tue Aug 4 13:11:33 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id NAA17624 for freebsd-hackers-outgoing; Tue, 4 Aug 1998 13:11:33 -0700 (PDT) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from picnic.mat.net ([209.118.174.117]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id NAA17524 for ; Tue, 4 Aug 1998 13:10:56 -0700 (PDT) (envelope-from chuckr@glue.umd.edu) Received: from localhost (chuckr@localhost) by picnic.mat.net (8.8.8/8.8.5) with SMTP id PAA01548; Tue, 4 Aug 1998 15:09:11 -0400 (EDT) Date: Tue, 4 Aug 1998 15:09:11 -0400 (EDT) From: Chuck Robey X-Sender: chuckr@picnic.mat.net 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: > Hi there, > > A question about C and static initialization of unions: > > suppose, > > union foo_t { > int i; > char c; > void *p; > }; > > static union foo_t bar = { (void *)&anyvar }; > > The compiler says "warning, making integer from pointer without a cast"... > Which is true and could lead to bad asm code. > > Is there a way to do this properly? Should I forgive unions or what else? No, you forgot to mention which union memeber to use. Your foo_t.p would do nicely. > > -- > Nicolas.Souchu@prism.uvsq.fr > FreeBSD - Turning PCs into workstations - http://www.FreeBSD.org > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-hackers" in the body of the message > > ----------------------------+----------------------------------------------- Chuck Robey | Interests include any kind of voice or data chuckr@glue.umd.edu | communications topic, C programming, and Unix. 213 Lakeside Drive Apt T-1 | Greenbelt, MD 20770 | I run Journey2 and picnic (FreeBSD-current) (301) 220-2114 | and jaunt (NetBSD). ----------------------------+----------------------------------------------- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message