簡體   English   中英

我們可以定義一個預處理器宏,該宏根據計時器打印調試消息嗎?

[英]Can we define a pre-processor macro which prints debug messages based on timer?

我想打印/記錄一條調試消息,如果滿足條件且在特定間隔后必須打印調試消息。 是否有可能使計時器滴答聲成為預處理器定義的一部分?

是否有可能使計時器滴答聲成為預處理器定義的一部分?

當然是啦。

偽代碼:

#define LOG_MESSAGE(args)      \
  if ( enoughTimeHasPassed() ) \
  {                            \  
     log_message(args);        \
  }

哪里

int enoughTimeHasPassed()
{
  // Return true/false based on whether enough time has passed
  // since the last call to the function.
}

void log_message(argtype args)
{
   // Implement the logic to log the message
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM