mirror of
https://github.com/netwide-assembler/nasm
synced 2026-08-26 16:23:04 -04:00
nasmlib.h: add convenience macros for iterating over fixed arrays
Iterating over fixed arrays is a common operation; add macros to simplify the task. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
This commit is contained in:
parent
e0d5333a47
commit
61b525fbc1
1 changed files with 4 additions and 0 deletions
|
|
@ -309,6 +309,10 @@ const char *filename_set_extension(const char *inname, const char *extension);
|
|||
* the number of elements of a statically defined array.
|
||||
*/
|
||||
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
|
||||
#define ARRAY_END(arr) (&(arr)[ARRAY_SIZE(arr)])
|
||||
#define array_for_each(var,arr) \
|
||||
for ((var) = (arr); (var) < ARRAY_END(arr); (var)++)
|
||||
|
||||
|
||||
/*
|
||||
* List handling
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue