Pack is a struct, union, and class member alignment to specify the byte boundary. different from the/ZP switch of the compilation option (property> Configuration property> C/C ++> code generation> structure member alignment), it is not applicable to
Transferred from: https://www.cnblogs.com/ransn/p/5081198.htmlFirst, the conceptAlignment is related to the location of the data in memory. If the memory address of a variable is exactly the integer multiple of its length, he is called natural
Reprint Address: http://blog.csdn.net/21aspnet/article/details/6729724First, the conceptAlignment is related to the location of the data in memory. If the memory address of a variable is exactly the integer multiple of its length, he is called
refer to a set of function pack,unpack before looking at the following example. Any language with socket operation has a function dedicated to the package, PHP is no exception of course this set of functions is not just a package.Here's a quick
C + + compiler instruction #pragma pack pairing use
#pragma pack can be used to specify the value of the memory alignment of a member variable of a C + + data structure (optional value is 1,2,4,8,16).
This article focuses on the use of pack
1 introIn the program, sometimes when we define the structure, we use #pragma pack (push,1) & #pragma pack (POP) similar code to wrap the structure together.The general form is as follows:#pragma pack (push,1);struct A{} ;#pragma pack (POP);What is
This is the parameter setting for the compiler, for the structure byte alignment setting, #pragma pack is the alignment of the specified data in memory.
#pragma pack (n) Action: The C compiler will be aligned by N bytes.#pragma pack () Effect:
Pack and unpack are not really easy to see in normal programs, but if you use PHP from a long time ago to generate Excel you will know. The head of his Excel is the pack.
Recently, when I tried to interact with C, I used this thing again, so I had
#pragma pack (4)//4-byte aligned, but in fact the maximum number of bytes consumed by a single member in a struct is 2 bytes, so it is actually aligned by 2 bytestypedef struct{Char buf[3];Word A;}KK;#pragma pack ()//de-Custom byte alignmentThe
Pack and unpack are not really easy to see in normal programs, but if you use PHP from a long time ago to generate Excel you will know. The head of his Excel is the pack.Recently, when I tried to interact with C, I used this thing again, so I had to
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.