KallistiOS git master
Independent SDK for the Sega Dreamcast
|
General useful language macros More...
Macros | |
#define | __build_assert(cond) do { (void) sizeof(char [1 - 2*!(cond)]); } while(0) |
Assert a build-time dependency. | |
#define | __build_assert_or_zero(cond) (sizeof(char [1 - 2*!(cond)]) - 1) |
Assert a build-time dependency. | |
#define | __array_size(arr) (sizeof(arr) / sizeof((arr)[0]) + _array_size_chk(arr)) |
Get the number of elements in a visible array. | |
#define | _array_size_chk(arr) 0 |
General useful language macros
This group contains definitions to help give robust solutions to common code patterns.
#define __array_size | ( | arr | ) | (sizeof(arr) / sizeof((arr)[0]) + _array_size_chk(arr)) |
Get the number of elements in a visible array.
This does not work on pointers, or arrays declared as [], or function parameters. With correct compiler support, such usage will cause a build error (
arr | The array whose size you want. |
#define __build_assert | ( | cond | ) | do { (void) sizeof(char [1 - 2*!(cond)]); } while(0) |
Assert a build-time dependency.
Your compiler will fail if the condition isn't true, or can't be evaluated by the compiler. This can only be used within a function.
Example:
cond | The compile-time condition which must be true. |
#define __build_assert_or_zero | ( | cond | ) | (sizeof(char [1 - 2*!(cond)]) - 1) |
Assert a build-time dependency.
Your compiler will fail if the condition isn't true, or can't be evaluated by the compiler. This can be used in an expression: its value is "0".
Example:
cond | The compile-time condition which must be true. |
#define _array_size_chk | ( | arr | ) | 0 |