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
main.c(11):error C2146: syntax error : missing ';' before identifier 'next_user' Line 5 has the original compilation error
Compilation error in inline function
main.c(6) : error C2146: syntax error : missing ';' before identifier 'next_user'
About our authors: Team EQA
You have viewed 1 page out of 248. Your C learning is 0.00% complete. Login to check your learning progress.
Questions index C Questions C++ Questions Win32 MFC COM/DCOM DLL Questions
Compilers & Editors
Download Visual Studio Download XCode Download Visual Studio Code Android studio install sdk Eclipse installer Best C compilers IDEs
Development system setup
Windows media creation tool MSDN subscription Ubuntu virtualbox
New updated posts
Why learn C? Calculate weighted average