2
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
4

1 に答える 1

5

次を使用して簡単に試すことができます:-

debug(a, b, c);

また、コマンドラインを変更する必要があります-DDEBUG -- the -D is "define"。現在、あなたは を定義しています"EBUG"

于 2013-09-30T15:23:30.437 に答える