28

I am using MSVS 2006 and trying to find time in microseconds in my program. I try to call sys/time.h in the header but this error is compiled.

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

and this is my code,

#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);
}
CiaranWelsh
  • 7,014
  • 10
  • 53
  • 106
Mazaya Jamil
  • 285
  • 1
  • 4
  • 7
  • mazaya-jamil, can you please share which solution worked for you? –  Jun 03 '17 at 10:51
  • There is sys\timeb.h – BlenderBender Feb 16 '18 at 17:03
  • Unfortunately, there is no sys\time.h header file in MSVC. Instead, try one of the following links for some help coding this on Windows. [stackoverflow 1676036](https://stackoverflow.com/questions/1676036/what-should-i-use-to-replace-gettimeofday-on-windows) [stackoverflow 2494356](https://stackoverflow.com/questions/2494356/how-to-use-gettimeofday-or-something-equivalent-with-visual-studio-c-2008) – lordjeb Sep 02 '14 at 22:48
  • 2
    is a POSIX header, not part of the C/C++ standard library. If you are using C++ the standard header is – Udith Indrakantha Jun 25 '21 at 07:32
  • Please try using #include instead. – bruce Mar 16 '23 at 02:07

0 Answers0