Programming‎ > ‎C‎ > ‎

Macro

1. #define cat(x,y) x##y concatenates x to y. But cat(cat(1,2),3) does not expand but gives preprocess warning, why?
    Rules of macro defines that it should not be recursive.
 
2. Macro and inline functions
    They are efficient than calling a normal function, with reduced overhead of function stack.
    They increase the size of the code.
 
    Inline functions are parsed by the compiler while macro are expanded by the preprocessor.
    Inline functions follow all the protocols of the type safety enforced on normal functions.
    Inline is a request, compiler could ignore it.
    Expressions passed as an argument to inline functions are evaluated once. In some cases for macro, they could be evaluated more than once.
Comments