Added 'difference between macros and functions'part (#32372)

I have explained the basic differences between macros and functions.
This commit is contained in:
Papun Charan
2019-02-19 22:05:00 -08:00
committed by Manish Giri
parent f2b3e2091a
commit 853311c57a

View File

@ -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)