Macro and inline function are very similar. Compiler expands macro where it is called and inline functions are also copied to the place where it is called.
They both increase code size as compiler copies object code to the location where these are getting called.
However they are not same and differences between macro and inline functions are:
Typed arguments vs untyped arguments
Inline functions take defined typed arguments where as macros can take any type as argument.
inline int swap(int *a, int *b);
#define swap(a, b)
Macros are expanded by the preprocessor before compilation takes place. Compiler will refer error messages in expanded macro to the line where the macro has been called.
Compilation error in macro
current_user = x \
next_user = x + 1;
int main (int argc, char *argv)
int user = 10;
main.c(11):error C2146: syntax error : missing ';'
before identifier 'next_user'
Line 5 has the original compilation error