diff options
| author | Richard Qin <richard.qin.x@gmail.com> | 2026-09-28 00:34:30 +0800 |
|---|---|---|
| committer | Richard Qin <richard.qin.x@gmail.com> | 2026-09-28 00:34:30 +0800 |
| commit | 1009f20d8ecdf1b8edd56b8cad94e850c07efae0 (patch) | |
| tree | 43dbe7483d895c83f3517de38c9d00fa5a4cd00f /lab02/container_of.h | |
| parent | 428f98fbd446ebdf6646e17af97c46d9b79b1143 (diff) | |
| download | RUCDSA-1009f20d8ecdf1b8edd56b8cad94e850c07efae0.tar.gz RUCDSA-1009f20d8ecdf1b8edd56b8cad94e850c07efae0.tar.xz | |
Implement vector in C
Diffstat (limited to 'lab02/container_of.h')
| -rw-r--r-- | lab02/container_of.h | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lab02/container_of.h b/lab02/container_of.h index 6383572..87fb6d4 100644 --- a/lab02/container_of.h +++ b/lab02/container_of.h @@ -11,7 +11,13 @@ #define typeof_member(T, m) typeof(((T*)0)->m) - +/** + * container_of - cast a member of a structure out to the containing structure + * @ptr: the pointer to the member. + * @type: the type of the container struct this is embedded in. + * @member: the name of the member within the struct. + * + */ #define container_of(ptr, type, member) ({ \ _Static_assert(__same_type(*(ptr), typeof_member(type, member)) || \ __same_type(*(ptr), void), \ |
