.
Correspondingly, is macro or inline function better?
The basic difference between inline and macro is that an inline functions are parsed by the compiler whereas, the macros in a program are expanded by preprocessor. The compiler may not inline and expand all the functions defined inside a class. On the other hand, macros are always expanded.
Secondly, why macros are faster than function? Macro execution is faster than function execution because in function, much of time is used to take control from function call to called function and much of time is spent in this process. Whereas in macro expression are directly replaced in the source code.
Similarly, it is asked, what is the advantage of inline functions over macros?
Answer: Advantage: Macros and Inline functions are efficient than calling a normal function. The times spend in calling the function is saved in case of macros and inline functions as these are included directly into the code. Macro is expanded by preprocessor and inline function are expanded by compiler.
Why inline functions are faster?
Inline functions are faster because you don't need to push and pop things on/off the stack like parameters and the return address; however, it does make your binary slightly larger. Marking something inline does not give you a guarantee that it will be inline. It's just a suggestion to the compiler.