From 853311c57a2f7780690f337faedbda83e4a4793a Mon Sep 17 00:00:00 2001 From: Papun Charan <42942897+richard937@users.noreply.github.com> Date: Tue, 19 Feb 2019 22:05:00 -0800 Subject: [PATCH] Added 'difference between macros and functions'part (#32372) I have explained the basic differences between macros and functions. --- guide/english/c/macros/index.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/guide/english/c/macros/index.md b/guide/english/c/macros/index.md index bb57a694c2..3aa496137f 100644 --- a/guide/english/c/macros/index.md +++ b/guide/english/c/macros/index.md @@ -110,6 +110,12 @@ void foo() { } ``` +#### Differences between Macros and Functions +1. The main difference is that macros are preprocessed which means all macros will be processed before the program compiles but functions are not, functions are compiled. +2. You cannot do recursion in macro but in function you can. +3. Speed of execution is faster in macros than in functions. +4. There is no type checking in macros but it is done in functions. + #### More Information: - [GCC Online Documentation: Macros](https://gcc.gnu.org/onlinedocs/cpp/Macros.html) - [GCC Online Documentation: Object-like macros](https://gcc.gnu.org/onlinedocs/cpp/Object-like-Macros.html#Object-like-Macros)