Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!cmcl2!rutgers!princeton!udel!rochester!PT.CS.CMU.EDU!H.GP.CS.CMU.EDU!cef From: cef@H.GP.CS.CMU.EDU (Charles Fineman) Newsgroups: comp.lang.c Subject: Re: void declarations and casts Message-ID: <220@PT.CS.CMU.EDU> Date: Fri, 23-Oct-87 03:43:51 EST Article-I.D.: PT.220 Posted: Fri Oct 23 03:43:51 1987 Date-Received: Sun, 25-Oct-87 15:11:34 EST References: <359@targon.UUCP> Sender: netnews@PT.CS.CMU.EDU Organization: Carnegie-Mellon University, CS/RI Lines: 36 Keywords: void, casts, declarations, assignments Summary: Of *course* it wont work!!! First to the declaration: *Whenever* you try to declare something that the C compiler does not know the size of, it complains. For example, you can say: struct foo; as a forward declaration and then say: struct foo *ptr; later in your code to get a pointer to a structure of type foo but you can't say: struct foo var; because it dosn't know the size of the thing. Its the same exact thing for the void type. Since C dosn't know what size a thing of type void should be, you can't declare a variable of that type. ** One iteresting side note: there was a discusion a while ** ago on some newsgroup about some folks declaring: ** typedef void *generic_pointer; As for casting to type void, there is no problem here as long as you realize that the *specified* semantics of this is to throw away the value. Hence, casting anything to void makes it *not* an rvalue (i.e. something we get a value of). Sure, you program is sytactically correct, but then so was that bogus fortran program that sent that poor satalite careening off to where no man has gone before ;-) Charles Fineman Carnegie-Mellon University cef@h.cs.cmu.edu (via seismo)