简体   繁体   中英

Can we add non-Packed structure element to Packed structure

Is it allowed to have non-packed structure member inside a packed structure?

Something like this:

packed struct{
    int a;
    un-packed struct b;
    int c;
};

Yes, it is allowed. The unpacked structure is a normal type from the point of view of the compiler and the packeds structure will, technically, remain packed.

But, in a common sense, the packed structure will not be actually packed - there may be some bytes unused in the unpacked structure and hence in the packed structure.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM