Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert milliseconds to timespec for GNU port

Tags:

I want to convert milliseconds into timespec structure used by GNU Linux. I have tried following code for the same.

  timespec GetTimeSpecValue(unsigned long milisec)
  {
    struct timespec req;
    //long sec = (milisecondtime /1000);
    time_t sec = (time_t)(milisec/1000);
    req->tv_sec = sec;
    req->tv_nsec = 0;
    return req;
  }

Running this code gives me the following error.

expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘GetTimeSpecValue’

I have also include time.h file in the code.