Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!motcid!kreidler From: kreidler@cell.mot.COM (Joe Kreidler) Newsgroups: comp.lang.c Subject: Memory allocation of structures Message-ID: <1457@navy8.UUCP> Date: 5 Mar 90 15:06:40 GMT Distribution: usa Organization: Motorola Inc. - Cellular Infrastructure Div., Arlington Heights, IL 60004 Lines: 39 For the 64000, structures are word aligned. What I didn't realize is that the end of the structure is also word aligned. Let me explain what I mean by the previous sentence with an example. Given the following declaration: struct { short a; short b; short c; } foo; short x; For the compiler I'm using, "short" is an 8-bit integer. "foo" is word aligned and uses three bytes. However, "x" is also word aligned. Since "x" follows a structure it starts on a new word boundary. This doesn't make sense to me. If the above declaration was changed to short a; short b; short c; short x; then "x" would use the byte directly following "c". I was expecting the first declaration to be allocated the same way. Is there some reason for structures being allocated memory as I described above? Is this observation part of the ANSI standard? Any insights are appreciated. Thanks in advance, Joe ------------------------------------------------------------ Joe Kreidler, Motorola C.I.D 1501 W Shure Drive ...!uunet!motcid!kreidler Arlington Heights, IL 60004 708-632-4664 ------------------------------------------------------------