











#pragma pack(n), where n is 1, 2, 4, 8, or 16:
each structure member after the first is stored on the smaller member type or n-byte boundaries.
A example will give a more direct impression:
#pragma pack(8)
struct A {
char c;
int i;
};
so sizeof(A) is 8;
while
#pragma pack(1)
struct A {
char c;
int i;
};
then sizeof(A) is 5.
PS. There is a little funny when I first encounter this preprocessor. I guess pack(8) is to force to align at 8b, but in fact the true meaning is 8B.
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。