Casting call
geacc022%timevx at cit-hamlet.arpa
geacc022%timevx at cit-hamlet.arpa
Sat May 18 01:45:41 AEST 1985
>This discussion has brought up another point -- somebody posted an example
>where he casted a lhs, and somebody pointed out that you can't do that.
>What I am wondering is, why can't you? There seem to be no semantic problems
>involved, and it can be very useful for something like:
>
>#define FREE(ptr) free(char *) ptr); (char *) (ptr) = (char *) -1;
There are indeed problems with this. What if you're on a machine
where char * is 32 bits, but int * is only 16 bits?
What you really want is a "typeof" operator:
#define FREE(ptr) { free((char *) ptr); ptr = (typeof ptr) NULL; }
Unfortunately, this doesn't exist either. :-(
Gary Ansok
GEACC022%TIMEVX @ CIT-HAMLET.ARPA
GEA @ CALTECH.BITNET
...ucbvax!cithep!timevx#geacc022
"All the world loves a straight man."
More information about the Comp.lang.c
mailing list