dimanche 12 juillet 2020

Having difficulty using a debbuger macro

Here is the code:

void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) {
    cerr << to_string(h); if (sizeof...(t)) cerr << ", ";
    DBG(t...); }

#ifdef _DEBUG
#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#else
#define dbg(...) 0
#endif

Im currently using g++ on vs code on a mac and whenever I run my program using this and for example I write dbg(10) on main the program does not even run and does not do anything(it outputs nothing).

How can I change this code so it would work on g++ without having to download clang? Note: I saw some people use #ifdef LOCAL instead of #ifdef _DEBUG but it still doesn't work for me(does not output anything). How do I get #ifdef LOCAL or #ifdef _DEBUG to work on g++?

Aucun commentaire:

Enregistrer un commentaire