0 votes
in C Plus Plus by
What is the difference between macro and functions?

1 Answer

0 votes
by

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. 

MacroFunction
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.

Related questions

0 votes
asked Jan 9 in C Plus Plus by GeorgeBell
0 votes
asked Jan 4 in C Plus Plus by GeorgeBell
...