请问这段代码有问题吗?

sws_martian 2009-12-18 03:39:23
为什么总是报错:
/tmp/ccAh9CTD.o: In function `main':
time.c:(.text+0x12): undefined reference to `clock_gettime'
time.c:(.text+0x2a): undefined reference to `clock_gettime'

#include <time.h>
#include <stdio.h>

void main()
{
struct timespec start;
struct timespec end;

clock_gettime(CLOCK_REALTIME,&start);
printf("hello world\n");
clock_gettime(CLOCK_REALTIME,&end);

printf("start: seconds %d,nanoseconds %d \n",start.tv_sec,start.tv_nsec);
printf("end: seconds %d,nanoseconds %d \n",end.tv_sec,end.tv_nsec);


}
...全文
75 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
dumeifang 2009-12-18
  • 打赏
  • 举报
回复
加上 -lrt
james_hw 2009-12-18
  • 打赏
  • 举报
回复
clock_gettime确定在<time.h> 里面么?应该是没有定义

69,372

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧