generic pointers (was: #define void int vs. #define void char)
Doug Gwyn
gwyn at brl-smoke.ARPA
Tue Jun 7 18:30:59 AEST 1988
In article <4420 at haddock.ISC.COM> karl at haddock.ima.isc.com (Karl Heuer) writes:
>In article <11823 at mimsy.UUCP> chris at mimsy.UUCP (Chris Torek) writes:
>>Indeed, this is the root of an objection I have to the `void *' syntax
>>for generic pointers. Had the standard included the line
>> typedef void *pointer_t; /* or (char *) */
>>in <stddef.h>, one could implement pointer_t on old compilers virtually
>>painlessly.
Old C implementations don't have <stddef.h>. Chris's suggestion would
amount to a Standard C requirement that everybody define "pointer_t",
but by the Standard it can only be defined one way, namely "void *".
That's hardly worthwhile. (The other *_t types provide implementations
with the opportunity to make a choice; this one wouldn't.)
There is nothing to keep you from having your own private standard
header that defines special types. I've had one for many years; it
defines a "bool" (Boolean) type and a "pointer" (generic pointer)
type, among other things. It is easy to tweak this header when
porting to a new system. In fact, the definition of "pointer" could
be under control of "#if __STDC__".
>My temporary workaround is to use "Void *" (note the capital V) for generic
>pointers.
This amounts to the same thing. I prefer to give the generic pointer
itself a type, rather than just a piece of it.
More information about the Comp.lang.c
mailing list