using namespace std;
#ifdef DEBUG
#define debug(args...) {dbg,args; cerr<<endl;}
#else
#define debug(args...) // Just strip off all debug tokens
#endif
struct debugger
{
template<typename T> debugger& operator , (const T& v)
{
cerr<<v<<" ";
return *this;
}
} dbg;
int main(){
int a=1,b=2,c=3;
debugger(a,b,c);
}
我找到了这个调试宏,我正在尝试使用它,但这不起作用。我收到以下错误:
ubuntu:~ g++ -DEBUG a.cpp -o a
a.cpp: In function ‘int main()’:
a.cpp:81:16: error: no matching function for call to ‘debugger::debugger(int&, int&, int&)’
a.cpp:81:16: note: candidates are:
a.cpp:62:8: note: debugger::debugger()
a.cpp:62:8: note: candidate expects 0 arguments, 3 provided
a.cpp:62:8: note: debugger::debugger(const debugger&)
a.cpp:62:8: note: candidate expects 1 argument, 3 provided