[C/C++] 如何得知 structure 的 member 在經過 alignment 後的 pad size ( offsetof macro 和 container_of macro )
日前在 ptt 逛 C/C++ 程式板時,偶然看到有人詢問如何得知 structure 的 pad bytes 有多少,推文中有人提及一個例子。而推文者提及的方法,其中較令人玩味的地方,在於對 0 做 dereference 的動作,因為我之前沒有注意到這樣的用法,覺得這作法非常有趣,拜訪過 google …