首页 > 代码库 > 字节对齐 pragma

字节对齐 pragma

 1 #include <iostream>21 #define KKK22 #define TT23 24 #pragma pack(2)  //define to 225 struct test_t26 {27        int a;28        char b;29        short c;30        char d;31 };32 #pragma pack()    //cancle define by user33 34 35 using namespace std;36 37 int main()38 {39     40 #if defined( KKK ) && defined (TT)41     cout << "dslfjsdlfjdslfdjs" << endl;42 #endif    43                   44      // that will be 1045     cout << "sizeof(test_t): " << sizeof(test_t) << endl;46 47     string d;48     cin >> d;49     return 0;50 }

 

字节对齐 pragma