1

我在 stackoverflow 上阅读了很多关于网络字节序的帖子。
例如,如果我做这样的事情:

struct timeval start_t
gettimeofday(&start_t, NULL);

现在,我怎么能确定这种演员阵容会奏效呢?

uint32_t receivedTime = someGetterSomewhere();
struct timeval result = (struct timeval) receivedTime;
struct timeval diffTime;
timersub(&start_t,&result,&diffTime);


// do stuff like timersub, etc to get ms elapsed time 

int calculatedTime =  (int) floor( ((diffTime.tv_sec) * 1000 + (diffTime.tv_usec) / 1000) + 0.5);

谢谢回答

PS:

我的 Gcc 说这是不允许的

error: aggregate value used where an integer was expected
         pkt_set_timestamp(emptyPacket, (const uint32_t) start_t);
4

0 回答 0