Array and member size helpers.
More...
|
| #define | ARRAY_LENGTH(array) (sizeof((array)) / sizeof((array)[0])) |
| | Calculate the length of an array, based on the size of the element type.
|
| |
| #define | STATIC_ARRAY_LENGTH(type, array) (sizeof((type[])array) / sizeof(type)) |
| | Get the number of elements of an array literal, as a compile-time constant.
|
| |
| #define | MEMBER_SIZE(type, member) sizeof(((type *)0)->member) |
| | Get the size of a structure member without an instance.
|
| |
Array and member size helpers.
◆ ARRAY_LENGTH
| #define ARRAY_LENGTH |
( |
|
array | ) |
(sizeof((array)) / sizeof((array)[0])) |
Calculate the length of an array, based on the size of the element type.
- Parameters
-
| array | The array to be evaluated. |
- Returns
- The length of the array.
◆ MEMBER_SIZE
| #define MEMBER_SIZE |
( |
|
type, |
|
|
|
member |
|
) |
| sizeof(((type *)0)->member) |
Get the size of a structure member without an instance.
- Parameters
-
| type | Structure type. |
| member | Member name. |
- Returns
- Size of the member in bytes.
◆ STATIC_ARRAY_LENGTH
| #define STATIC_ARRAY_LENGTH |
( |
|
type, |
|
|
|
array |
|
) |
| (sizeof((type[])array) / sizeof(type)) |
Get the number of elements of an array literal, as a compile-time constant.
#define RATES {10, 25, 50}
static const uint16_t s_rates[] = RATES;
#define STATIC_ARRAY_LENGTH(type, array)
Get the number of elements of an array literal, as a compile-time constant.
Definition size.h:33
- Parameters
-
| type | Type of the elements. |
| array | Brace-enclosed array literal. |
- Returns
- Number of elements.