From: Jack Klein Newsgroups: comp.os.msdos.djgpp Subject: Re: BIG problem with structure alignment! Message-ID: <6j8ritgiss20bunpjt7fhdv0vskb3va575@4ax.com> References: <001101c0f7a6$837b46a0$cf10a2cb AT lunar> X-Newsreader: Forte Agent 1.8/32.548 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 66 Date: Mon, 18 Jun 2001 06:45:25 GMT NNTP-Posting-Host: 12.84.8.100 X-Complaints-To: abuse AT worldnet DOT att DOT net X-Trace: bgtnsc04-news.ops.worldnet.att.net 992846725 12.84.8.100 (Mon, 18 Jun 2001 06:45:25 GMT) NNTP-Posting-Date: Mon, 18 Jun 2001 06:45:25 GMT Organization: AT&T Worldnet To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com On Mon, 18 Jun 2001 10:22:27 +0700, "Lunar" wrote in comp.os.msdos.djgpp: > This is a multi-part message in MIME format. Please don't do this. Usenet discussion groups are text only. Find the Outlook Express options for posting to newsgroups and set it to text only. > ------=_NextPart_000_000D_01C0F7E0.92BD7A40 > Content-Type: text/plain; > charset="iso-8859-1" > Content-Transfer-Encoding: quoted-printable > > Hi you all, > I've met this problem with structure declaration: > I did have a struct like this: > struct T1{ > char _t1; > short _t2; > }; > > and the sizeof(T1) return a result of 4, instead of 3 as I expected. Why = > is that? If it's because of some aligment option, then could you help me = > turn them off? > Please mail me at lunarorb AT hn DOT vnn DOT vn if you can help Asking for private email responses in technical discussion groups is considered rude. > Thanks > Lunar > > ------=_NextPart_000_000D_01C0F7E0.92BD7A40 > Content-Type: text/html; > charset="iso-8859-1" > Content-Transfer-Encoding: quoted-printable > > > > http-equiv=3DContent-Type> > > > > >
Hi you all,
>
I've met this problem with structure=20 > declaration:
>
I did have a struct like = Both the C and C++ languages allow the compiler to add padding between the members of a structure and after the last member for alignment purposes. The only place that padding is not allowed is in front of the first member of the structure. Why do you have a problem with this? DJGPP programs can access many megabytes of data, do you have that many of these structures? -- Jack Klein Home: http://JK-Technology.Com FAQs for comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html comp.lang.c++ http://www.parashift.com/c++-faq-lite/ alt.comp.lang.learn.c-c++ ftp://snurse-l.org/pub/acllc-c++/faq