[英]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.