我想打印/记录一条调试消息,如果满足条件并且在特定时间间隔后,则必须打印调试消息。是否可以使计时器滴答声成为预处理器定义的一部分?
最佳答案
Is it possible to make timer ticks part of pre-processor defines?
当然是这样。
伪代码:
#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
}
关于我们可以定义一个预处理器宏来根据计时器打印调试消息吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40669908/