title: Field tv_sec could not be resolved
body: <p>I am trying to run the following code snippet taken from <a href="http://cc.byexamples.com/2007/03/14/create-a-timer/" rel="nofollow">this simple example of a timer</a>:</p>
  
  <pre><code>#include &lt;sys/time.h&gt;
  #include &lt;stdio.h&gt;
  
  int SetTimer(struct timeval &amp;tv, time_t sec) {
      gettimeofday(&amp;tv, NULL);
      tv.tv_sec += sec;
  
      return 1;
  }
  
  int CheckTimer(struct timeval &amp;tv, time_t sec) {
      struct timeval ctv;
      gettimeofday(&amp;ctv, NULL);
  
      if ((ctv.tv_sec &gt; tv.tv_sec)) {
          gettimeofday(&amp;tv, NULL);
          tv.tv_sec += sec;
          return 1;
      } else {
          return 0;
      }
  }
  
  int main() {
      struct timeval tv;
      SetTimer(tv, 5); //set up a delay timer
      printf("start counting.\n");
      while (1)
          if (CheckTimer(tv, 5) == 1)
              printf("Welcome to cc.byexamples.com\n");
      return 0;
  }
  </code></pre>
  
  <p>I am obtaining the following error: field <code>tv_sec</code> could not be resolved</p>
  
  <p>I have searched for it on the Web but no one seems to give a concrete answer.</p>
  
  <p>I tried my chance looking into the libraries <code>sys/time.h</code> and <code>time.h</code> but in none of them seems to be defined this structure but is anyway used.</p>
  
  <p>Am I missing any library? Since this example is rather old, did something changed that needs it to be done in a different way? I would appreciate any sight.</p>
  
  <p>PS: I am using Eclipse CDT Indigo under Ubuntu 11.10 and g++ 4.6.1.</p>