2016-11-18 33 views

回答

1

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

當然可以。

僞代碼:

#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 
}