c++ if (调试) ..."=="标记之前的预期主表达式

c++ if (DEBUG) ... expected primary-expression before '==' token

本文关键字:表达式 if 调试 c++      更新时间:2023-10-16
  #define DEBUG 1
  void senddata() {
  ...
  if (DEBUG==1) {
  cout << row->Printable () << endl;
  };
  ....
  }

getrow.cc:在函数 'void senddata()' 中:getrow.cc:277:错误:"=="标记之前的预期主表达式

IMO 代码几天前正在运行... - 知道这里出了什么问题吗?

我根本不会那样做。这似乎更合适:

#ifdef DEBUG
    cout << row->Printable() << endl;
#endif

如果您做错了什么(例如在某处忘记了分号),这也会产生更好的警告和错误。