Skip to content
UPEEC

Preprocessor Macros

`#define` creates object-like and function-like macros expanded before compilation.

Easy
Comments 0
#define ARRAY_LEN(a) (sizeof(a) / sizeof((a)[0]))
#define BIT(n)       (1u << (n))

# stringifies, ## pastes tokens. Prefer static inline functions and const/enum when possible.

Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.

Discussion (0)

Sign in or join free to ask questions and discuss this topic.