I set my pack level to 1 when I'm dealing with structures that will be
written to disk... and don't want them aligned..
#pragma pack(1)
struct CDMSSegmentHeader
{
char HeaderID[16]; // HeaderID
UBYTE SegmentID[16]; // Unique Segment ID
DWORD DocID; // Original Document ID
DWORD Page; // Original Page Number
DWORD Version; // Original Version of Page
DWORD CRC; // CRC 32
DWORD Type; // Segment Type
DWORD Flags; // Extra Flags
DWORD ActualSize; // Original Data Size
DWORD CompressedSize; // Size of Compressed Data
DWORD EncryptedSize; // Size of Encrypted Data
SYSTEMTIME TimeDate; // TimeStamp
char FileName[64]; // FileName
char FileExt[8]; // File Extension
DWORD FileType; // File Type
};
#pragma pack()
----- Original Message -----
From: "Neil" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Tuesday, March 22, 2005 12:50 PM
Subject: Re: [msvc] sizeof(..) query..
> What do you recommend I set the pack to? And how do I use it? A small
> example please?
>
> Thanks
> neil
>
>
> ----- Original Message -----
> From: "Ehsan Akhgari" <[EMAIL PROTECTED]>
> To: <[email protected]>
> Sent: Monday, March 21, 2005 1:29 PM
> Subject: RE: [msvc] sizeof(..) query..
>
>
> >> One option would be to manually set the packing options for the
> >> structure in the header file.
> >>
> >> #pragma pack(push)
> >> #pragma pack(8) // Or something sensible.
> >> typedef struct
> >> {
> >> // Whatever.
> >> } STRUCT;
> >> #pragma pack(pop)
> >>
> >> But provided you stick to the same build options and always use the
> >> MSVC compiler you should be safe without these safeguards..
> >
> > But using these #pragma's is too easy to miss out. I'd never rely on
> > compiler internals on such stuff. I would specify the packing
explicitly
> > and rest assured that they'd be applied no matter what.
> >
> > -------------
> > Ehsan Akhgari
> >
> > Farda Technology (http://www.farda-tech.com/)
> >
> > List Owner: [email protected]
> >
> > [ Email: [EMAIL PROTECTED] ]
> > [ WWW: http://www.beginthread.com/Ehsan ]
> >
> > But the thought is one thing, the deed another, and the idea of the deed
> > still another. The wheel of causality does not roll between them.
> > -Thus Spoke Zarathustra, F. W. Nietzsche
> >
> >
> >
> >
> > _______________________________________________
> > msvc mailing list
> > [email protected]
> > See http://beginthread.com/mailman/listinfo/msvc_beginthread.com for
> > subscription changes, and list archive.
> >
> >
> >
>
>
>
>
> _______________________________________________
> msvc mailing list
> [email protected]
> See http://beginthread.com/mailman/listinfo/msvc_beginthread.com for
subscription changes, and list archive.
>
_______________________________________________
msvc mailing list
[email protected]
See http://beginthread.com/mailman/listinfo/msvc_beginthread.com for
subscription changes, and list archive.