Browse - Programming Tips - How can I make sure there is no padding in my C struct (on Win32) ?

Date: 2008dec3
Platform: win32
Language: C/C++
Keywords: pack, packing, packed, padding, zero, tightly

Q.  How can I make sure there is no padding in my C struct (on Win32) ?

A.  Use these includes:

#include <pshpack1.h> typedef struct { BYTE a[3]; BYTE b[4]; BYTE c[5]; } MY_STRUCT; #include <poppack.h>