alignment of struxures

cottrell at nbs-vms.ARPA cottrell at nbs-vms.ARPA
Fri Jan 4 09:32:26 AEST 1985


/*
1) why not make all struxures unaligned, requiring explicit alignment
   by the programmer? pdp-11 (& vax?) assemblers require an explicit
   '.even' or such. i know it's a burden, but then any struxure would
   be possible.
2) in the meantime, try this:

	#define BYTE(x)	(*((char *)(x)))
	#define WORD(x) (*((short*)(x)))
	#define LONG(x) (*((long *)(x)))

then

	struct ugly {
		char	a;
		char	longint[4];	/* really a long int */
		...
	} yuk;

to get the long int do:

	barf = LONG(yuk.longint);

3) have fun!

*/



More information about the Comp.lang.c mailing list