Article View: borland.public.cppbuilder.nativeapi
Article #13848Re: alignment
From: Antonio Farfan
Date: Thu, 18 Sep 2003 08:10
Date: Thu, 18 Sep 2003 08:10
54 lines
2808 bytes
2808 bytes
Hi:
Now This is my definition with padding that it�s working well.
unsigned __int8 fNumbeForegin[20];
char PaddingPIN[3] ;
TSettings fProfileSettings[1];
struct TProfileSettings
{
__int8 fModeState;
__int8 fAscendingState;
__int8 fToneState;
char fAudio[14];
char padding[3];
}
I have proved with alignment Dword and Word, but they don�t work well.
"Bob Gonder" <notbg@notmindspring.invalid> escribi� en el mensaje
news:kb6hmv0pa8o95ursa78l00hjlem1ghsu8q@4ax.com...
> Antonio Farfan wrote:
>
> >Now I solve the problem with the option of compiler of Bytes (Alignment)
but
> >i have to add fields of padding in the struct. This is my problem. This
> >procedure is not very graceful. If there are any change in the Struct i
need
> >to readjust the paddings.You can read my first email.
>
> There are 53 bytes before your problem sub-structure.
> If you need 1 byte of padding, then you need WORD alignment.
> If you need 3, then you need DWORD alignment
>
> TSettings is 17 bytes, so it is going to throw off the alignment for
> alarmRecord also (unless you need WORD alignment).
> Since you haven't mentioned alarmRecord being incorrect, you probably
> need WORD alignment.
> Either
> #pragma option -a2
> or
> #pragma pack(push,2)
>
>
> If you still can't get it to work,
> Repost just the one structure definition TPS_Settings;
> Show us the "padding" that makes it "work" with byte alignment.
>
>
>
Technical Details
Message-ID:
<3f69671b$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-04!sn-xit-06!sn-xit-09!supernews.com!newshosting.com!news-xfer2.atl.newshosting.com!216.166.71.118.MISMATCH!small1.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<3f673746@newsgroups.borland.com> <3f674494$1@newsgroups.borland.com> <3f6749b2$1@newsgroups.borland.com> <3f676a91@newsgroups.borland.com> <3f688407@newsgroups.borland.com> <3F688926.EF20C0EF@sbcglobal.net> <3f688cb6$1@newsgroups.borland.com> <kb6hmv0pa8o95ursa78l00hjlem1ghsu8q@4ax.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: 10cc67,a9334a47483d8c0e X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-09-18 01:20:58 PST From: "Antonio Farfan" <amfm0777@hotmail.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <3f673746@newsgroups.borland.com> <3f674494$1@newsgroups.borland.com> <3f6749b2$1@newsgroups.borland.com> <3f676a91@newsgroups.borland.com> <3f688407@newsgroups.borland.com> <3F688926.EF20C0EF@sbcglobal.net> <3f688cb6$1@newsgroups.borland.com> <kb6hmv0pa8o95ursa78l00hjlem1ghsu8q@4ax.com> Subject: Re: alignment Date: Thu, 18 Sep 2003 10:10:38 +0200 Lines: 56 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 NNTP-Posting-Host: 62.15.230.33 Message-ID: <3f69671b$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1063872283 62.15.230.33 (18 Sep 2003 01:04:43 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-04!sn-xit-06!sn-xit-09!supernews.com!newshosting.com!news-xfer2.atl.newshosting.com!216.166.71.118.MISMATCH!small1.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail