Hi,
I was hoping that someone can help me with this. When I ran the below codes, it stated that there is an implicit declaration of set_timer in line 6. But my set_timer function has already been declared after the main(). Why is this so?
C Code:
#include<stdio.h>
#include<sys/time.h>
#include<signal.h>
#include<unistd.h>
int main() {
if(set_ticker(500) == -1)
perror("set_ticker");
else
while(1) pause();
return 0;
}
int set_ticker(int n_msecs) {
struct itimerval new_timeset;
long n_sec, n_usecs;
n_sec = (n_msecs/1000);
n_usecs = (n_msecs % 1000) * 1000L;
new_timeset.it_interval.tv_set = n_sec;
new_timeset.it_interval.tv_usec = n_usecs;
new_timeset.it_value.tv_sec = n_sec;
new_timeset.it_value.tv_usec = n_usecs;
return setitimer(ITIMER_REAL, &new_timeset, NULL);
}
Will appreciate help, thanks in advance!