Dave's Brain

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>

Add a comment

Sign in to add a comment
Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.