title: I am trying to implement timer using c in ubuntu, but receiving errors of declaration
body: <p>please help me, i want to implement timer using c in ubunto. i have  the written the code but it is giving two errors. I am compiling it using -lrt option of gcc.
  Errors i am getting is:
  timer1.c: In function ‘main’:
  timer1.c:18:52: error: ‘SIG’ undeclared (first use in this function)
  timer1.c:18:52: note: each undeclared identifier is reported only once for each function it appears in
  timer1.c:21:23: error: ‘handler’ undeclared (first use in this function)</p>
  
  <p>My code is:</p>
  
  <pre><code>#include &lt;stdlib.h&gt;
  #include &lt;unistd.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;signal.h&gt;
  #include &lt;time.h&gt;
  
  timer_t timerid;
  
  int main(int argc, char *argv[])
  {
  
  
             struct sigevent sev;
             struct itimerspec its;
             long long freq_nanosecs;
             sigset_t mask;
             struct sigaction sa;
      printf("Establishing handler for signal %d\n", SIG);
  
      sa.sa_flags = SA_SIGINFO;
      sa.sa_sigaction = handler;
      sigemptyset(&amp;sa.sa_mask);
  
  
      sev.sigev_notify = SIGEV_SIGNAL;
      sev.sigev_signo = SIG;
      sev.sigev_value.sival_ptr = &amp;timerid;
  
   printf("timer ID is 0x%lx\n", (long) timerid);
  //    timer_create(CLOCKID, &amp;sev, &amp;timerid);
      /* Start the timer */
  
      its.it_value.tv_sec = 1000;
      its.it_value.tv_nsec =0;
      its.it_interval.tv_sec = its.it_value.tv_sec;
      its.it_interval.tv_nsec = its.it_value.tv_nsec;
  
      timer_settime(timerid,0, &amp;its, NULL);
      sleep(10);
  
  
  }
  
  
   static void handler(int sig, siginfo_t *si, void *uc)
  {
     if(si-&gt;si_value.sival_ptr != &amp;timerid)
      {
          printf("Stray signal\n");
          } 
    else 
      {
          printf("Caught signal from timer\n");
          }
  
  
  }
  </code></pre>