0
我想打印/記錄一個調試消息,如果條件滿足並且在特定時間間隔之後必須打印調試消息。是否有可能使計時器滴答聲預處理器定義的一部分?我們可以定義一個基於計時器打印調試消息的預處理器宏嗎?
我想打印/記錄一個調試消息,如果條件滿足並且在特定時間間隔之後必須打印調試消息。是否有可能使計時器滴答聲預處理器定義的一部分?我們可以定義一個基於計時器打印調試消息的預處理器宏嗎?
是否有可能使計時器滴答預處理器定義的一部分?
當然可以。
僞代碼:
#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
}