Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site elsie.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxl!houxm!houxz!vax135!cornell!uw-beaver!tektronix!hplabs!hao!seismo!rlgvax!cvl!elsie!ado From: ado@elsie.UUCP Newsgroups: net.lang.c Subject: Re: Why 'void *' is useful Message-ID: <1013@elsie.UUCP> Date: Tue, 10-Jul-84 21:16:21 EDT Article-I.D.: elsie.1013 Posted: Tue Jul 10 21:16:21 1984 Date-Received: Fri, 13-Jul-84 03:09:23 EDT References: <274@lvbull.UUCP>, <8260@watmath.UUCP> Organization: NIH-LEC, Bethesda, MD Lines: 39 > A non-sensical use of 'void' would be to declare an object of type void > (not function-returning-void). e.g. > f() { > void x; /* Now what do I do with it? */ > ... > } What do you do with it? Take "sizeof x", of course. :-) A possibly sane use would be as a place-holder for "obsolete" elements of structures stored in files. Suppose you have a bunch of files, each of which contains a structure like: typedef struct { int fortran; int pascal; int c; } languages; Now suppose you want to stop using "fortran" and "pascal", and yet want to be able to retrive the information in the "c" element of previously-stored structures. You might want to: typedef struct { void int fortran; void int pascal; int c; } languages; to enforce discontinuation of use of the "obsolete" elements while preserving the ability to get at the "c" elements in the files. Currently, you can do this by declaring unnamed bit fields; doing this is machine dependent, given the varying number of bits per int (or whatever) on different machines. Of course, it STILL doesn't make sense in the above example for "void" to stand alone--here, it's being used as an adjective. -- ...decvax!allegra!umcp-cs!elsie!ado (301) 496-5688 (the DEC and VAX in decvax are Digital Equipment Corporation trademarks)