在linux下,container_of
宏被封閉在看似 「多餘」 的括號:爲什麼我們需要圍繞宏塊的括號?
#define container_of(ptr, type, member) ({ \
const typeof(((type *)0)->member) *__mptr = (ptr);
(type *)((char *)__mptr - offsetof(type,member));})
取而代之的是,我們可以只使用
#define container_of(ptr, type, member) { \
const typeof(((type *)0)->member) *__mptr = (ptr);
(type *)((char *)__mptr - offsetof(type,member));}
?
圓括號是強制性還是僅用於預防?
這應被標記GCC而不是C ....... –