共用方式為


編譯器警告 (層級 4) C4820

在成員建構 'member_name' 之後加入 'bytes' 位元組填補

元素的型別與順序使編譯器在結構的結尾加入填補。 如需關於在結構中加入填補的詳細資訊,請參閱align

此警告在預設情況下為關閉的。 如需詳細資訊,請參閱預設為關閉的編譯器警告

下列範例會產生 C4820:

// C4820.cpp
// compile with: /W4 /c
#pragma warning(default : 4820) 

// Delete the following 4 lines to resolve.
__declspec(align(2)) struct MyStruct {
   char a;
   int i;   // C4820
};

// OK
#pragma pack(1)
__declspec(align(1)) struct MyStruct2 {
   char a;
   int i;
};