希望這是一個簡單的問題,並帶有一個簡單的答案。代碼用C編寫。 我使用MPLAB IDE v1.60和XC8編譯器,但它不識別「clock_t」。我將MPLAB設置爲器件PIC18F6520。 當我嘗試構建時出現的錯誤消息如下;clock_t沒有用MPLAB XC8編譯
ClockTimer.c:16: error: undefined identifier "clock_t"
ClockTimer.c:16: error: expression syntax
ClockTimer.c:18: error: expression syntax
ClockTimer.c:19: error: undefined identifier "stop"
ClockTimer.c:19: error: undefined identifier "start"
代碼如下;
#include <stdio.h>
#include <stdlib.h>
#include <xc.h>
#include <time.h>
int main()
{
clock_t start = clock();
// Execuatable code
clock_t stop = clock();
double elapsed = (double)(stop - start) * 1000.0/CLOCKS_PER_SEC;
printf("Time elapsed in ms: %f", elapsed);
}
任何想法,爲什麼這不是編譯? 感謝 馬克
閱讀編譯器文檔,可能庫不支持這些功能。 –