hun_offsetof
Provides C-like macros: offsetof and containerof
和memoffset crate的区别- Differences between crate memoffset and crate self
- 基于指针操作,不占用栈空间,支持超大数据结构,无栈溢出风险
- Pointer-based opertions do not occupy stack space, support super-large data structures, and avoid stack overflow risks.
- 提供container_of操作
- Provides the container_of operation.
基于指针的操作属于unsafe范围,如果使用声明宏方式,可能出现嵌套unsafe的编译告
警,而过程宏可以消除这类告警。
Pointer-based operations are unsafe, If the declaration macro mode is used, nested unsafe compilation warnings may be generated, which can be eliminated by procedure macro.