Disadvantages of #define,
1. Preprocessor not doing type checking
2. May not store variable in symbol table
3. Need to care for parenthesis
4. Preprocessor hard code #define variable. Code size become bulky
5. Any changes in macro , need to re-compile all source code.
1. Compile Time error
Error encounter while compiling program by compiler, like syntax error, type checking errors etc.
For example, Declare preprocessor variable in header file and same use in another source
file. At time of compilation, compiler never know about preprocessor variable as preprocessor
replace it with it's macro value and Preprocessor variable may not store into symbol table for debugging purpose.
It make sometime difficult to trace error root point if we had not written header file.
2. Run time Error
Error encounter at time of executing program by operating system, like referencing null pointer,
insufficient memory for allocation etc.
Example, If macro body has not taken care with parenthesis on mathematical operations.
Macro Example :
using namespace std;
#define MAX_SIZE 1000000000
#define FUNC(a,b) a*b
//1. Compile Time Error
int* pArr = new int[MAX_SIZE];
//2. Run Time Error