Must casting destroy lvalueness?

stephen at datacube.UUCP stephen at datacube.UUCP
Thu Oct 23 23:19:00 AEST 1986


I generally use or define caddr_t as the type of a generic pointer, and then
use macros to perform the indicated operations, i.e.:

caddr_t generic_pointer;

#define DATA( p, type ) (*((type *)(p)))
#define SUCC( p, type ) ((p) += sizeof(type))
#define PRED( p, type ) ((p) -= sizeof(type))

a = DATA(p,int);
SUCC(a, int);
b = DATA(p,double);
SUCC(p, double);

In the case of a compiler where the cast in DATA is invalid, an 
alternate formulation can be made.


Stephen Watkins                    UUCP: ihnp4!datacube!stephen
Datacube Inc.; 4 Dearborn Rd.; Peabody, Ma. 01960; 617-535-6644



More information about the Comp.lang.c mailing list