error when passing pointer to struct to function in c

I'm trying to pass pointers to two `struct timevals` to a function that would output the elapsed time between the two in a C program. However, even if I dereference these pointers, nvcc throws the error "expression must have class type" (this is a CUDA program). Here is the relevant code from main(): struct timeval begin, end; if (tflag) { HostStartTimer(&begin) }; // CUDA Kernel execution if (tflag) { HostStopTimer(&begin, &end); } And the function definition for HostStopTimer(): void HostStopTimer(struct timeval *begin, stuct timeval *end) { long elapsed; gettimeofday(end, NULL); elapsed = ((*end.tv_sec - *begin.tv_sec)*1000000 + *end.tv_usec - *begin.tv_usec); printf("Host elapsed time: %ldus\n", elapsed); } The line causing the error is the assignment to `elapsed`. I don't have much experience using structs in C, much less passing pointers to structs to functions, so I'm not sure what is causing the error.

以上就是error when passing pointer to struct to function in c的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » CSS3 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏