Define CONTAINER

Define Documentation

CONTAINER(ptr, structure, member)

Find parent object from a member pointer.

Subtracts the byte offset of the member in the structure from the pointer to the member itself, giving a pointer to parent structure.

Note

Both GCC and Clang will type-check this macro.

Parameters
  • ptr – Pointer to a member data field of a structure

  • structure – Type name of the parent structure

  • member – Field name of the data member

Returns

Pointer to the parent structure