Important: The information in this document is obsolete and should not be used for new development.
The Get Link Object Macro
Open Transport defines a macro (OTGetLinkObject) that you can use to easily cast back to the original object from a pointer to either a LIFO or a FIFO linked list structure.
DataType* OTGetLinkObject(OTLink* linkPtr, DataType structName, NameOfLinkPtrField fieldName)
#define OTGetLinkObject(link, struc, field)- \
((struc*)((char*)(link) - offsetof(struc, field)))PARAMETERS
linkPtr- A pointer to the
OTLinkstructure from which you wish to cast back.structName- The name of the structure containing the
OTLinkstructure.fieldName- The
OTLinkfield in the above structure.- function result
- The macro results in a pointer to the appropriate data type by offsetting the
linkPtrappropriately and casting the result.