Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!tut.cis.ohio-state.edu!ucbvax!agate!shelby!csli!poser From: poser@csli.Stanford.EDU (Bill Poser) Newsgroups: comp.lang.c Subject: Re: casting to a union Message-ID: <11426@csli.Stanford.EDU> Date: 13 Dec 89 07:42:04 GMT Sender: news@csli.Stanford.EDU Reply-To: poser@csli.stanford.edu (Bill Poser) Organization: Center for the Study of Language and Information, Stanford U. Lines: 9 Perhaps the simplest point to note about why (union numstr) 7 is no good is to keep in mind that unions really are aggregates. It is easy to fall into the trap of thinking of a union as a type abstraction, so that a union that can hold either a character point or an integer is a type that is one or the other, but that isn't the case from C's point of view. Rather, a union is an aggregate just like a struct except for the fact that the members share storage. So the reason you can't cast 7 to (union numstr) is the same reason that you can't cast it to a struct or an array.