can';t使用struct tms编译代码 #如果定义(有#次) #包括 静态双循环_diff(结构tms*a,结构tms*b) { 时钟\u t aa=a->tms\u使用时间+ a->tms\u时间+ a->tms_皮肤+ a->tms_cstime; 时钟bb=b->TMS使用时间 +b->tms\u时间 +b->tms_皮肤 +b->tms_cstime; 返回(aa bb)/(双)系统配置(SCCLK TCK); } }

can';t使用struct tms编译代码 #如果定义(有#次) #包括 静态双循环_diff(结构tms*a,结构tms*b) { 时钟\u t aa=a->tms\u使用时间+ a->tms\u时间+ a->tms_皮肤+ a->tms_cstime; 时钟bb=b->TMS使用时间 +b->tms\u时间 +b->tms_皮肤 +b->tms_cstime; 返回(aa bb)/(双)系统配置(SCCLK TCK); } },time,compiler-errors,tms,Time,Compiler Errors,Tms,这会产生错误 struc tms的不完整类型声明 及 没有声明sysconf 您需要#包括 #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

这会产生错误

struc tms的不完整类型声明

没有声明sysconf

您需要
#包括

#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);
  }
}