最近遇到这样一段有bug的代码:
#include<stdio.h>
#include<unistd.h>
#include <stdint.h>
#include <sys/time.h>
//微秒
uint64_t get_usec()
{
struct timeval now;
gettimeofday(&now, NULL);
return now.tv_sec * 1000000 + now.tv_usec;
}
int main()
{
printf("%llu usec\n", get_usec());
return 0;
}
秒破上述bug.
因为:https://blog.csdn.net/stpeace/article/details/54674392