Path: utzoo!attcan!uunet!tcs!nujoizey!gwu From: gwu@nujoizey.tcs.com (George Wu) Newsgroups: comp.lang.c++ Subject: Re: Byte padding question Message-ID: <1023@tcs.tcs.com> Date: 14 Sep 90 23:59:25 GMT References: <440@mole-end.UUCP> Sender: usenet@tcs.com Reply-To: gwu@nujoizey.tcs.com (George Wu) Distribution: comp Organization: Teknekron Communications Systems Lines: 30 In article <440@mole-end.UUCP>, mat@mole-end.UUCP (Mark A Terribile) writes: |> > When building a class hierarchy in C++ we found that some extraneous |> > char's were being inserted into the C structure produced by the AT&T front |> > end. |> > |> > [ stuff about empty structs deleted ] |> > |> > I also noticed that in it's child class the |> > extra byte generated for the empty base class was added as well as a new char |> > array of size 1. |> |> > In the work our department is doing, this will cause problems in |> > the future and we would like to clear up the reason why this is |> > happening (and even better how to stop it happening!). |> |> [ more stuff deleted ] |> |> The array in the derived class is *probably* there to force subsequent |> data members back to the ``correct'' or machine optimal alignment. After |> a non-array char member, the next member can be begun at an odd boundary |> if the machine will support it. Nah, that can't be it. The C compiler already does that for you. The C++ compiler/translator should never have to do alignment explicitly. ---- George J Wu | gwu@tcs.com or ucbcad!tcs!gwu Software Engineer | 2121 Allston Way, Berkeley, CA, 94704 Teknekron Communications Systems, Inc.| (415) 649-3752