You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

11 lines
242 B
C

#pragma once
#include <stddef.h>
#include "typecheck.h"
#define CONTAINER_OF(PTR, TYPE, MEMBER) ({ \
CHECK_TYPE(__typeof__(((TYPE *)NULL)->MEMBER), *(PTR)); \
(TYPE *)((char *)(PTR) - offsetof(TYPE, MEMBER)); \
})