Skip to content

Latest commit

 

History

History
36 lines (29 loc) · 1001 Bytes

compiler-warning-level-4-c4820.md

File metadata and controls

36 lines (29 loc) · 1001 Bytes
description title ms.date f1_keywords helpviewer_keywords ms.assetid
Learn more about: Compiler Warning (level 4) C4820
Compiler Warning (level 4) C4820
11/04/2016
C4820
C4820
17aa29f4-c287-49b8-bc43-8ed82ffed5ea

Compiler Warning (level 4) C4820

'bytes' bytes padding added after construct 'member_name'

The type and order of elements caused the compiler to add padding to the end of a struct. See align for more information on padding in a struct.

This warning is off by default. See Compiler Warnings That Are Off by Default for more information.

The following sample generates 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;
};