gpt4 book ai didi

CLOCKS_PER_SEC 未声明(首次在此函数中使用)

转载 作者:可可西里 更新时间:2023-11-01 11:49:22 28 4
gpt4 key购买 nike

这是我程序的一部分;

double get_cpu_time(){
return (double)clock() / CLOCKS_PER_SEC;

但是我得到以下错误;

In function ‘get_cpu_time’: timertest.c:13:30: error: ‘CLOCKS_PER_SEC’ undeclared (first use in this function)

我包含的头文件是;

 #include<stdio.h>
#include<math.h>
#include <sys/time.h>

操作系统为Ubuntu12.04(刚刚安装)。

为什么会这样?

最佳答案

您需要包括 <time.h> 而不是 <sys/time.h> .

关于CLOCKS_PER_SEC 未声明(首次在此函数中使用),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20541791/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com