use of pragma pack!! Urgent..

hi,

what is the use if pragma pack in c++.

what is the difference in giving the pragma pack(1) and if it is not defined?
eg:
in my code if i declare pragma pack(1)
struct a
{
int b;
};

and for the same eg if i didnt declare pragma pack how will it make difference?

can plz help me inthis?
Packing concerns the binary layout of a struct or class. The items are always placed on a boundary of some kind. If the items follow directly onto the next byte, you're said to have byte alignment, forced by #pragm pack(1) in Microsoft's C/C++ compiler. You can force other boundaries, such as 4 byte boundaries.

Why? Some hardware can only access members on specific boundaries. Some hardware are more efficient on specific boundaries. Some environments can't afford to waste the space resulting from non single byte alignment.

It's a design decision.
Topic archived. No new replies allowed.