Always same effect of #pragma pack(16) and #pragma pack(8)?
问题 I am trying to align data members by using #pragma pack (n). Take the following as an example: #include <iostream> using namespace std; #pragma pack(8) // or (16) struct A { int a; char b; char c; char d; char e; char f; double g; }; int main() { cout << sizeof(A) << endl; return 0; } Both will print 24 for #pragma pack(8) and #pragma pack(16) . I can understand the result for n=8 with the data alignment, of my understanding, as follows: Bytes: |1 2 3 4|5|6|7|8|9|10 11 12 13 14 15 16|17 18 19