467,893 Members | 1,914 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,893 developers. It's quick & easy.

Byte Packing

How does the byte packing and the byte alignment work in VC++ compiler? What is the effect of #pragma pack(n) on the alignment and byte packing
for example while using the structur
struc

double a
char b
char c
}
in a 8 byte packing the sizeof structure is 16. Could anyone explain.
Nov 17 '05 #1
  • viewed: 2864
Share:
1 Reply
Gajendra wrote:
How does the byte packing and the byte alignment work in VC++
compiler? What is the effect of #pragma pack(n) on the alignment and
byte packing. for example while using the structure
struct
{
double a;
8 bytes.
char b;
1 byte
char c;
1 byte
6 bytes of padding to make the struct-size a multiple of 8. This is
necessary to ensure that in an array of structs that the 'a' member always
has 8-byte alignment.
};
in a 8 byte packing the sizeof structure is 16. Could anyone explain.


8+1+1+6=16

-cd
Nov 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by gbb0330 | last post: by
29 posts views Thread by Ed Morton | last post: by
4 posts views Thread by Shashi | last post: by
18 posts views Thread by Edward Diener | last post: by
9 posts views Thread by fraz | last post: by
18 posts views Thread by p.lavarre | last post: by
1 post views Thread by Asfar | last post: by
reply views Thread by shofu_au | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.