Skip to content

Instantly share code, notes, and snippets.

@s0cks
Created September 12, 2016 17:02
#ifndef container_of
#define container_of(ptr_, type_, member_)({ \
const typeof(((type_*) 0)->member_)* __mptr = ((void*) ptr_); \
(type_*)((char*) __mptr - offsetof(type_, member_)); \
})
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment