What's the use of _ATL_PACKING constant when computing distance from the start of object?
问题 ATL features a set of macros for so-called COM maps. COM map is a table that associates an interface GUID with an offset that is to be added to this pointer to get to the corresponding subobject - the whole stuff works as replacement to explicit static_cast for the upcast inside IUnknown::QueryInterface(). The map entries are built by using offsetofclass macro: #define _ATL_PACKING 8 #define offsetofclass(base, derived)\ ((DWORD_PTR)(static_cast<base*>((derived*)_ATL_PACKING))-_ATL_PACKING)