Featured image of post struct收紧结构编译器指令

struct收紧结构编译器指令

C++

C/C++编译器指令 attribute((packed)) 会告诉编译器不要对齐,收紧结构,这样struct的大小就是成员大小的和。

struct xfs_agfl {
        __be32          agfl_magicnum;
        __be32          agfl_seqno;
        uuid_t          agfl_uuid;
        __be64          agfl_lsn;
        __be32          agfl_crc;
} __attribute__((packed));

xfs里这个AGFL(allocation group free internal list) 就用到了这个东西。

Licensed under CC BY-NC-SA 4.0
comments powered by Disqus
Built with Hugo
Theme Stack designed by Jimmy