Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ #pragma pack

What does the following statement actually do and what are it's effects?

#pragma pack(push,8)
like image 747
Tony The Lion Avatar asked Oct 25 '10 12:10

Tony The Lion


1 Answers

It pushes the current pack setting onto a stack (so that you can restore it later via pop) and then sets the alignment for struct elements to 8 bytes. Anything which is not naturally aligned to an 8 byte boundary will have padding bytes inserted before it to maintain the required alignment.

like image 54
Paul R Avatar answered Oct 14 '22 15:10

Paul R