Newsgroups: comp.lang.c Path: utzoo!henry From: henry@utzoo.uucp (Henry Spencer) Subject: Re: Variable-length messages. Message-ID: <1988Oct22.231317.19640@utzoo.uucp> Organization: U of Toronto Zoology References: <919@goofy.megatest.UUCP> Date: Sat, 22 Oct 88 23:13:17 GMT In article <919@goofy.megatest.UUCP> djones@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, and enough existing code assumes this that there should be relatively few compilers that violate it. (Of course, this is little comfort if you are constrained to use such a compiler...) -- The meek can have the Earth; | Henry Spencer at U of Toronto Zoology the rest of us have other plans.|uunet!attcan!utzoo!henry henry@zoo.toronto.edu