About Store Forum Documentation Contact



Post Reply 
how to use #pragma pack( push, 1) at EE editor
Author Message
rect Offline
Member

Post: #1
how to use #pragma pack( push, 1) at EE editor
Hi every one.

I write a struct like that
Code:
#pragma pack( push, 1)
struct SPackage
   {
  
      U16   u16Test; // 2 bit
      U8    u8Test; // 1 bit
      U32   u32Test1; // 4 bit
      U32   u32Test2; // 4 bit
      U64   u64Test; // 8 bit
      U32   u32Test3; // 4 bit
      SPackage()
      {
         ZeroN(&T, 1);
      }
  
   }
#pragma pack(pop)

at other editor.

sizeof(SPackage) must be (2 + 1 + 4 + 4 + 8 + 4) = 23 bit

but at EE editor sizeof(SPackage) is 40.

my question is:
1.Why?
2.how to use #pragma pack at EE Editor?
(This post was last modified: 05-26-2015 10:22 AM by rect.)
05-26-2015 10:21 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Pixel Perfect Offline
Member

Post: #2
RE: how to use #pragma pack( push, 1) at EE editor
Please see the following post and reply: pragma pack
05-26-2015 12:22 PM
Find all posts by this user Quote this message in a reply
Zervox Offline
Member

Post: #3
RE: how to use #pragma pack( push, 1) at EE editor
Also correction, it is bytes not bits.
05-27-2015 02:28 AM
Find all posts by this user Quote this message in a reply
rect Offline
Member

Post: #4
RE: how to use #pragma pack( push, 1) at EE editor
thanks,i can use now,just written like that:


struct SPackage
{
#pragma pack( push, 1)
U16 u16Test; // 2 bit
U8 u8Test; // 1 bit
U32 u32Test1; // 4 bit
U32 u32Test2; // 4 bit
U64 u64Test; // 8 bit
U32 u32Test3; // 4 bit
#pragma pack(pop)
SPackage()
{
ZeroN(&T, 1);
}

}
05-28-2015 03:14 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply