AP_Common: added ARRAY_SIZE_SIMPLE()

this works with zero length arrays
This commit is contained in:
Andrew Tridgell 2018-01-12 12:49:09 +11:00
parent 468cadca45
commit 7aeab8f5a8
1 changed files with 3 additions and 0 deletions

View File

@ -79,6 +79,9 @@ char (&_ARRAY_SIZE_HELPER(T (&_arr)[0]))[0];
#define ARRAY_SIZE(_arr) sizeof(_ARRAY_SIZE_HELPER(_arr))
// simpler ARRAY_SIZE which can handle zero elements
#define ARRAY_SIZE_SIMPLE(_arr) (sizeof(_arr)/sizeof(_arr[0]))
/*
* See UNUSED_RESULT. The difference is that it receives @uniq_ as the name to
* be used for its internal variable.