data-structures-c
Loading...
Searching...
No Matches
container_of.h File Reference

container_of definition More...

Go to the source code of this file.

Macros

#define container_of(ptr, type, member)
 Obtain a pointer to the struct that contains the member.
 

Detailed Description

Macro Definition Documentation

◆ container_of

#define container_of ( ptr,
type,
member )
Value:
__extension__({ \
const typeof(((type *)0)->member) *__mptr = (ptr); \
(type *)((char *)__mptr - offsetof(type, member)); \
})

Obtain a pointer to the struct that contains the member.

Parameters
[in]ptrPointer to the member.
[in]typeContainer type
[in]memberMember name.
Returns
A pointer to the struct containing the member.