【发布时间】:2014-03-06 12:42:51
【问题描述】:
void TASK(Task100ms_Raster)
{
int a,b,c;
struct timespec start, stop;
uint32 StartTime, StopTime;
uint32 duration100ms;
if( clock_gettime( CLOCK_REALTIME, &start) == -1 ) {
perror( "clock gettime" );
}
StartTime =start.tv_sec + 0.0000001 * start.tv_nsec;
printf("start time is %lu", StartTime);
printf("value is %d",c);
printf("ETAS1\n");
if( (StopTime = clock_gettime( CLOCK_REALTIME, &stop)) == -1 )
{
perror( "clock gettime" );
}
StopTime = stop.tv_sec + 0.0000001 * stop.tv_nsec;
printf("stop time is %lu", StopTime);
duration100ms = StopTime -StartTime;
printf( "time difference is= %lu\n", duration100ms );
}
我创建了一个计时器,它计算开始时间、停止时间和时间差。我对开始时间、停止时间和 suration100ms 的格式说明符感到困惑。但是 struct timespec 开始,停止;是http://www.qnx.com/developers/docs/6.3.0SP3/neutrino/lib_ref/t/timespec.html 类型,那么获得结果的正确格式说明符可能是什么。一些指导我。
【问题讨论】:
-
uint32不是标准类型。 -
我忘记添加 :typedef unsigned long uint32;
标签: c++ c linux timer format-specifiers