我正在尝试在我的C++代码中使用clock()
函数,但是它不起作用。我尝试添加#include <time.h>
或#include <ctime>
,但没有帮助。我正在使用Atmel Studio。
#include <time.h>
int main(void)
{
clock_t myClock = clock();
}
不应有错误,但我收到以下错误消息:
recipe for target 'SAMS70.elf' failed
undefined reference to `_times'
ld returned 1 exit status
有谁知道为什么会这样?
最佳答案
MCU通常不会暴露处理器的使用时间。库clock
函数调用所需的_times
函数以获取值,但是由于上述原因,未为MCU定义该函数。
关于c++ - 调用 `clock()`会产生错误:对 `_times'的 undefined reference ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58000219/