Casting NULL?

Peter at adm.UUCP Peter at adm.UUCP
Fri Jan 23 10:37:38 AEST 1987


Its me again, although not about my infamous reviewer.

I have a question about pointers: I just recently read
a C text where whenever NULL was passed as a parameter
it was casted to the proper type. For example, if he had

void test(pc,pi)
char *pc;
int *pi;
{
  ...
}

he would call it as

test( (char *)NULL, (char *)NULL );

if the parameters were to be passed as NULL. He claimed that
this is required because pointers to different types of objects
may not be the same size. I can appreciate this but how common
is it really? Are there any byte architectures out there where
a pointer to one type of object is a different size than a pointer
to another type of object? I know that under MS-DOS, some compilers
support so-called "far" declarations, but that's not really the
same. Would anyone care to respond?

Try sending to me directly to Peter at Acadia.BITNET. If that doesn't
work, just post it over info-c.

Peter Steele



More information about the Comp.lang.c mailing list