Following is the way to disable structure padding using pragma in C.
#pragma pack(push, 1)
//Define your structure here
#pragma pack(pop)
//Structure padding is re enabled.
More information can be found at MSDN. GCC follows the same specifications.
Structure padding is adding extra bits at the end of the structue,so that the structure completes the word boundary.
ReplyDeletehttp://clinuxpro.com/structure-padding
@Sandhya rephrasing the sentence a little. Structure padding is adding extra "bytes" at the end of structure "members" to make them aligned. For example,
ReplyDeletestrcut a {
char cA;
char cB;
int nA;
}
2 bytes will be added after char cB to make it 4 bytes region.