A commonly encountered C idiom is the CONTAINING_RECORD macro, which is typically defined like this
#define CONTAINING_RECORD(_Address_, _Type_, _Field_) \
    ((_Type_ *)( (PUINT8)(_Address_) - (PUINT8)(&((_Type_ *)0)->_Field_)))

In previous versions, VCC had dedicated support for this idiom, which required re-definition of CONTAINING_RECORD; recently, this special support has been eliminated and we rely on ordinary pointer arithmetic reasoning.

Last edited Jun 21, 2010 at 8:04 AM by stobies, version 4

Comments

No comments yet.