Pros and Cons of Different macro function / inline methods in C
- by Robert S. Barnes
According to the C FAQ, there are basically 3 practical methods for "inlining" code in C:
#define MACRO(arg1, arg2) do { \
/* declarations */ \
stmt1; \
stmt2; \
/* ... */ \
} while(0) /* (no trailing ; ) */
or
#define FUNC(arg1, arg2) (expr1, expr2, expr3)
To clarify this one, the arguments are used in the…