SIZEOF
Mike Lutz
mjl at ritcv.UUCP
Tue Jan 29 08:41:23 AEST 1985
> OK. Everybody take a deep breath and repeat after me:
>
> THER IS NO ONE NULL ADDRESS CONSTANT IN C!
>
> There is no such thing as a generic "pointer" in C.
Guy's right, of course. For those who want null pointers of various
types, might I suggest the following macro:
/*
* Make a Null Pointer for objects of type 't'
*/
#define NullPtr(t) ( ((t) *) 0 )
This permits code like:
execl( "/bin/foo", "foo", "bar", NullPtr(char) ) ;
This can be quickly fixed for those who object to creating pointers to
objects of type 't' but want Null pointers for (pointer) type t.
With a bit of imagination, you can create macros to allocate & free
objects of type 't' in a type safe fashion, using malloc/calloc/free.
--
Mike Lutz Rochester Institute of Technology, Rochester NY
UUCP: {allegra,seismo}!rochester!ritcv!mjl
CSNET: mjl%rit at csnet-relay.ARPA
More information about the Comp.lang.c
mailing list