data-structures-c
Loading...
Searching...
No Matches
lib
container_of.h
Go to the documentation of this file.
1
/* container_of.h
2
*
3
* Copyright (C) 2023 abxh
4
*
5
* This library is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU Lesser General Public
7
* License as published by the Free Software Foundation; either
8
* version 2.1 of the License, or (at your option) any later version.
9
* See the file LICENSE included with this distribution for more
10
* information. */
11
21
#pragma once
22
33
#ifndef container_of
34
#define container_of(ptr, type, member) \
35
__extension__({ \
36
const typeof(((type *)0)->member) *__mptr = (ptr); \
37
(type *)((char *)__mptr - offsetof(type, member)); \
38
})
39
#endif
Generated by
1.12.0