c++ - 调用 `clock()`会产生错误:对 `_times'的 undefined reference

标签 c++ embedded clock atmelstudio

我正在尝试在我的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/

相关文章:

c++ - 单击/按键时鼠标位置会改变吗?

c++ - C++ 中的 "poison a function"是什么意思?

linux - Eclipse 与 powerpc-linux-gcc 可能吗?

embedded - 如何通过在同一位置映射两个变量来重用物理内存?

python - 在 python 中每 5 分钟运行一次与系统时钟同步的函数的最佳方法是什么?

java - if 和 else 语句 Java 试图停止一条语句

C++:更改单个输出操作的格式输出

c - 浮点运算中的清零行为

c - clock_gettime 和 CLOCK_PROCESS_CPUTIME_ID 的数字错误

c++ - 我无法捕获和处理浮点异常?