As an example, the following is a simple macro defining a debug statement:
#ifdef DEBUG
#define Tdebug(stmts) { stmts; }
#else
#define Tdebug(stmts) ;
#endif
This allows the user to #define DEBUG in order to have debug statements
expanded. E.g., a complete code using this would be:
#include <iostream.h>
#include <assert.h>
#define DEBUG
#ifdef DEBUG
#define Tdebug(stmts) { stmts; }
#else
#define Tdebug(stmts) ;
#endif
main()
{
int i,j,n;
cin >> n;
assert(n<100);
for (j=0; j<n; j++){
for (i=0; i<n; i++){
if (i>4){
cout << "Exiting" << endl;
break;
}
Tdebug(
cout << "i = " <<
i << endl
);
}
}
}