Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site watmath.UUCP Path: utzoo!watmath!kpmartin From: kpmartin@watmath.UUCP (Kevin Martin) Newsgroups: net.lang.c Subject: Why 'void *' is useful Message-ID: <8260@watmath.UUCP> Date: Sun, 8-Jul-84 19:01:26 EDT Article-I.D.: watmath.8260 Posted: Sun Jul 8 19:01:26 1984 Date-Received: Mon, 9-Jul-84 01:24:29 EDT References: <274@lvbull.UUCP> Reply-To: kpmartin@watmath.UUCP (Kevin Martin) Organization: U of Waterloo, Ontario Lines: 20 Pete Delaney asks... >Why do we need void *, the 'universital pointer', the syntax is questionable? I think that the word was 'universal'. Perhaps 'generic' might have been a better word. Basically, it is a reasonable thing to do with a construct which would otherwise have to be made illegal. The idea is to have a pointer which cannot be dereferenced without casting it first. I find the syntax quite clear (In fact, this meaning for 'void *' has already been implemented in our C compilers... it was suggested after the compiler was found to be buggy in its treatment of casts into strange types). It is a pointer that, if an attempt is made to indirect through it, yields the illegal/unusable type 'void'. 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? */ ... }