title: Use of clock_getres - newbie Linux C
body: <p>I'm trying to determine the granularity of the timers on my Linux box.  According to the man pages for clock_getres, I should be able to use this snippet:</p>
  
  <pre><code>#include &lt;time.h&gt;
  #include &lt;stdio.h&gt;
  
  int main( int argc, char** argv )
  {
    clockid_t types[] = { CLOCK_REALTIME, CLOCK_MONOTONIC, CLOCK_PROCESS_CPUTIME_ID, CLOCK_THREAD_CPUTIME_ID, (clockid_t) - 1 };
  
    struct timespec spec;
    int i = 0;
    for ( i; types[i] != (clockid_t) - 1; i++ )
    {
      if ( clock_getres( types[i], &amp;spec ) != 0 )
      {
        printf( "Timer %d not supported.\n", types[i] );
      }
      else
      {
        printf( "Timer: %d, Seconds: %ld Nanos: %ld\n", i, spec.tv_sec, spec.tv_nsec );
      }
    }
  }
  </code></pre>
  
  <p>I'm trying to build like so:
      gcc -o timertest timertest.c</p>
  
  <p>This works great on Solaris but on Linux I get the error:</p>
  
  <pre>
  /tmp/ccuqfrCK.o: In function `main':
  timertest.c:(.text+0x49): undefined reference to `clock_getres'
  collect2: ld returned 1 exit status
  </pre>
  
  <p>I've tried passing -lc to gcc, apparently clock_getres is defined in libc, but it makes no difference.  I must be missing something simple here - any ideas?</p>
  
  <p>Thanks,</p>
  
  <p>Russ</p>