title: Getting problem with timing in C in visual studio 2010
body: <p>I have a function for getting system time. The function is defined as follows.</p>
  
  <pre><code>  int getSystemTime(struct timeval tv, void * tz);{
    DWORD milliseconds;
    milliseconds = timeGetTime();
    tv-&gt;tv_sec = milliseconds / 1000;
    tv-&gt;tv_usec = (milliseconds % 1000) * 1000;
    return 0;
    }
  </code></pre>
  
  <p>Precisely following are the problems:</p>
  
  <pre><code> 1.error: identifier DWORD is undentified .
   2.error: identifier timeGetTime() is undefined.
   3.error: identifier suseconds_t is undefined. 
  </code></pre>
  
  <p>I tried to include <code>windef.h</code> where DWORD is defined. But the problem is, I got the error like:</p>
  
  <pre><code> 1. error: identifier PCONTEXT is undefined.
  </code></pre>
  
  <p>The header file for time included is <code>time.h</code>. Here the timeval defined is:</p>
  
  <pre><code>#ifndef _WINSOCK_H
  struct timeval {
  time_t tv_sec;
  suseconds_t tv_usec;
  };
  </code></pre>
  
  <p>Could you please tell me what shall I do to make this function run in windows environment?</p>
  
  <p>[EDIT]</p>
  
  <pre><code> #ifdef HAVE_CONFIG_H
   #include "config.h"
   #endif
  
  #ifdef HAVE_WINDOWS_H
  #include &lt;windows.h&gt;
  #endif
  
  #ifdef HAVE_MMSYSTEM_H
  #include &lt;mmsystem.h&gt;
  #endif
  
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;sys/time.h&gt;
  </code></pre>