make macro ARRAY_SIZE() handle corner cases
Put the parameter in brackets to ensure it is an atom. This makes the macro work as expected in corner cases like ARRAY_SIZE(foo + 3) also. Signed-off-by: Axel Heider <axelheider@gmx.de>
This commit is contained in:
parent
ce73ba379d
commit
c673f1cded
1 changed files with 1 additions and 1 deletions
|
|
@ -41,7 +41,7 @@
|
|||
#define IS_ALIGNED(n, b) (!((n) & MASK(b)))
|
||||
#define ROUND_DOWN(n, b) (((n) >> (b)) << (b))
|
||||
#define ROUND_UP(n, b) (((((n) - UL_CONST(1)) >> (b)) + UL_CONST(1)) << (b))
|
||||
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
|
||||
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
||||
#define MIN(a,b) (((a)<(b))?(a):(b))
|
||||
#define MAX(a,b) (((a)>(b))?(a):(b))
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue