【发布时间】:2011-01-25 23:10:09
【问题描述】:
我对 Ubuntu 很陌生,但我似乎无法让它工作。它在我的学校计算机上运行良好,我不知道我没有在做什么。我已经检查了 usr/include 和 time.h 就可以了。代码如下:
#include <iostream>
#include <time.h>
using namespace std;
int main()
{
timespec time1, time2;
int temp;
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &time1);
//do stuff here
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &time2);
return 0;
}
我也使用 CodeBlocks 作为我的 IDE 来构建和运行。任何帮助都会很棒,谢谢。
【问题讨论】:
-
你也经常需要
-D_XOPEN_SOURCE=600。另请参阅GCC with -std=c99 complains about not knowing struct timespec。
标签: c++ linux ubuntu posix time.h