如何在窗口中使用sys / time.h?

时间:2014-09-02 03:52:44

标签: visual-c++ timer

我正在使用MSVS 2006并试图在我的程序中找到以微秒为单位的时间。我尝试在标题中调用sys / time.h但是编译了这个错误。

fatal error C1083: Cannot open include file: 'sys/time.h': No such file or directory
Error executing cl.exe.

这是我的代码,

#include<sys/time.h>
#include<stdio.h>
int main()
{
   struc timeval stop,start;
   gettimeofday(&start,NULL);

   /*my function here*/

   gettimeofday(&stop,NULL);
   printf("took %lu usec\n",stop.tv_usec-start.tv_usec);
}

1 个答案:

答案 0 :(得分:10)

不幸的是,MSVC中没有sys \ time.h头文件。相反,请尝试以下链接之一,以便在Windows上对此进行编码。

stackoverflow 1676036

stackoverflow 2494356