Liam0205 / liam0205.github.io

Deployment of my weblog.
https://liam0205.github.io
35 stars 5 forks source link

谈谈 C/C++ 中的 offsetof | 始终 #215

Open Liam0205 opened 5 years ago

Liam0205 commented 5 years ago

https://liam.page/2018/01/10/a-customized-offsetof-in-Cpp/

此篇讲一讲 C/C++ 中的 offsetof。

D0ngWen commented 5 years ago

博主写的很好,豁然开朗的感觉。 但是这个c语言实现版可能有点问题吧o(╯□╰)o 我从别的地方复制了一个:

define offsetof(s, m) ((int)((char)&((s )0)->m))