无法使用struct tms编译代码

时间:2011-07-27 07:14:02

标签: time compiler-errors tms

#if defined(HAVE_TIMES)
#include <unistd.h>
static double cycles_diff(struct tms *a,struct tms *b)
{

      clock_t aa = a->tms_utime  +
                   a->tms_stime  +
                   a->tms_cutime +
                   a->tms_cstime;

      clock_t bb = b->tmstms_utime
            +      b->tms_stime
            +      b->tms_cutime
            +      b->tms_cstime;

      return (aa-bb)/(double)sysconf(_SC_CLK_TCK);
  }
}

这会产生错误

  

struc tms的不完整类型声明

  

未声明sysconf

1 个答案:

答案 0 :(得分:1)

According to the manual您需要#include <sys/times.h>