我在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);