0
What is #pragma pack(1) in c++?
#pragma pack(1)
2 odpowiedzi
+ 1
#pragma pack(1) in c++ assures that all data members follow each other in the memory allignment without any padding.
Typically when a class is defined in c++, the compiler will add padding between data members in order to ensure that the members follow a certain byte boundary. But when you use #pragma pack(1), you make sure that there is no padding between any of the elements.
Memory alignment is important when it comes to performance however the compiler will make sure that your memory always has the most optimal allignment for your platform. You will very rarely want to use #pragma pack unless specified by an external library or code base.
+ 1
Thnx bro