First off, thank you very much for considering contributing to macros.h.
A good Macro is : Portable, safe, involves as less arbitrary variables as possible. Although I am trying my best, there might be some exception errors, please correct if you find any. Also, if I missed some other interesting macros, please contribute to make this collection complete and more usable.
- All macros are in UPPERCASE.
- In case of any Boolean Macro, the
IS_ prefix
should be used. For example,IS_EVEN(x)
. And they should return a1
or0
value. - Macros for loops and conditionals should not end with braces so that the user can have the option for single line as well as block style.
- A helper macro, which are expanded by some other main macro, usually they are not intended to be used directly. So they should be mentioned with their expansion level as prefix. For example,
PASTE(a,b)
expands intoPASTE2(a,b)
which further expands intoa##b
.