A macro is a name that is given to a block of C statements as a pre-processor directive. Macro is defined with the pre-processor directive. Macros are pre-processed which means that all the macros would be preprocessed before the compilation of our program. However, functions are not preprocessed but compiled.
Macro | Function |
---|
Macros are preprocessed. | Functions are compiled. |
Code length is increased using macro. | Code length remains unaffected using function. |
Execution speed using a macro is faster. | Execution speed using function is slower. |
The macro name is replaced by the macro value before compilation. | Transfer of control takes place during the function call. |
Macro doesn’t check any Compile-Time Errors. | Function check Compile-time errors. |