Dave's Brain

Browse - programming tips - tightly packed struct

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

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>
What this info useful to you? You can donate to say thanks

Add a comment

Sign in to add a comment
Copyright © 2008-2012, 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.
Advertisements: