Variable-length messages.

Dave Jones djones at megatest.UUCP
Tue Oct 25 05:43:02 AEST 1988


>From article <1988Oct22.231317.19640 at utzoo.uucp), by henry at utzoo.uucp (Henry Spencer):
) In article <919 at goofy.megatest.UUCP) djones at megatest.UUCP (Dave Jones) writes:
))) 	struct message {
))) 		int msgType;		/* msg type code */
))) 		int msgLength;		/* length of msg body */
))) 		char msgBody[1];	/* variable length msg body */
))) 	};
))
))This looks unsafe to me.  That one-char-long "msgBody" can be
))packed into the structure at any of a number of different places,
))depending on the compiler's alignment strategy.
) 
) No:  X3J11 specifically states that struct member addresses are in 
) ascending order ...

Is it not possible that one compiler might put msgBody on an
even address and another one put it on an odd address, and another
one put it on a double-word boundary?



More information about the Comp.lang.c mailing list