Common macros and compiler attributes/pragmas configuration. More...
Common macros and compiler attributes/pragmas configuration.
Definition in file container.h.
#include <stddef.h>#include <stdint.h>
Include dependency graph for container.h:
This graph shows which files directly or indirectly include this file:Go to the source code of this file.
| #define | container_of(PTR, TYPE, MEMBER) |
| Returns the container of a pointer to a member. | |
| #define | index_of(ARRAY, ELEMENT) |
| Returns the index of a pointer to an array element. | |
| #define | ARRAY_SIZE(a) |
| Calculate the number of elements in a static array. | |
| #define | STATIC_STRLEN(string) |
| Length of C string excluding the null terminator as an integer constant expression. | |
| #define ARRAY_SIZE | ( | a | ) |
Calculate the number of elements in a static array.
| [in] | a | Array to examine |
Definition at line 79 of file container.h.
| #define container_of | ( | PTR, | |
| TYPE, | |||
| MEMBER ) |
Returns the container of a pointer to a member.
For a struct TYPE with a member MEMBER, given a pointer PTR to TYPE::MEMBER this function returns a pointer to the instance of TYPE.
E.g. for struct my_struct_t { ...; something_t n; ... } my_struct;, &my_struct == container_of(&my_struct.n, struct my_struct_t, n).
| [in] | PTR | pointer to a member |
| [in] | TYPE | a type name (a struct or union), container of PTR |
| [in] | MEMBER | name of the member of TYPE which PTR points to |
Definition at line 58 of file container.h.
| #define index_of | ( | ARRAY, | |
| ELEMENT ) |
Returns the index of a pointer to an array element.
| [in] | ARRAY | an array |
| [in] | ELEMENT | pointer to an array element |
Definition at line 70 of file container.h.
| #define STATIC_STRLEN | ( | string | ) |
Length of C string excluding the null terminator as an integer constant expression.
| [in] | string | String literal expression or char array sized by initializer |
Use this macro to determine the length of a C string at compile-time, without resorting to strlen.
char * pointer variables.strlen given string literals or visible char buffers into integers at compile time, too. If the string contains additional null bytes, you should use strlen instead.Definition at line 116 of file container.h.