I am quite new to C++, and I am currently trying to add an appropriate template. I see that most of the good coders have some type of debugging statement such as the following:
void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }
#ifdef PRANAY_DEBUG
#define dbg(...) cerr << "(" << #__AA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif
int main() {
ios_base::sync_with_stdio(0);
#ifndef PRANAY_DEBUG
cin.tie(nullptr);
#endif
}
However, I am not sure how to use this. If I write dbg(a, b)
and run my program, I do not see any additional print statements in the terminal. I believe that this is because I am not passing the flag correctly, but I am not really sure what this means and/or how to best do this for a CP set-up. I have tried running g++ -PRANAY_DEBUG a.cpp
as some have suggested, but I get an unrecognized command line option error.