在windows ddk中提供了一個經典的宏,其定義如下:
#define CONTAININT_RECORD(address, type, field) \
((type*)((PCHAR)(address) - (PCHAR)(&((type*)0)->field)))
這個宏用于取得內存中任何結構體的首地址,要提供的參數是:結構體中某個成員(field)的地址address、結構體的類型type、提供地址那個成員的名字field。
posted on 2011-02-06 16:49
小王 閱讀(912)
評論(1) 編輯 收藏 引用 所屬分類:
VC