====== macros ====== * [[https://github.com/pfultz2/Cloak/wiki/C-Preprocessor-tricks,-tips,-and-idioms|C Preprocessor tricks, tips, and idioms]] * [[http://jhnet.co.uk/articles/cpp_magic]] * [[https://medium.com/codex/c-macros-pseudo-generic-methods-and-structs-b4236e6e50b8|C Macros: Pseudo-generic methods and structs]] #define MAX(a, b) \ ({ __typeof__(a) _a = (a); \ __typeof__(b) _b = (b); \ _a > _b ? _a : _b; }) ===== bitfields ===== #define BITMASK(bit_len, bit_shift) (((1U << (bit_len))-1) << (bit_shift))