C/C++ error: storage size of ‘tv’ isn’t known错误解决方法
来源:互联网 发布:淘宝食品如何备案 编辑:程序博客网 时间:2024/06/06 15:35
使用时间函数 gettimeofday() 时报错 “error: storage size of ‘tv’ isn’t known”,代码如下:
#include <stdio.h>#include <stdlib.h>#include <time.h>#include <sys/time.h> int main(){struct tim tv; struct timezone tz;gettimeofday (&tv , &tz);printf("===> tv_sec1: %ld\n", tv.tv_sec);printf("===> tv_usec1: %ld\n", tv.tv_usec);sleep(3);gettimeofday (&tv , &tz);printf("===> tv_sec2: %ld\n", tv.tv_sec);printf("===> tv_usec2: %ld\n", tv.tv_usec);return 0;}
使用 gcc 编译报错:
test.c: In function ‘main’:test.c:10: error: storage size of ‘tv’ isn’t known
于是仔细查了 gettimeofday 函数,发现函数的定义与我记得的有出入,正确的如下:
#include <sys/time.h>int gettimeofday(struct timeval *tv, struct timezone *tz);参考:
http://man7.org/linux/man-pages/man2/settimeofday.2.html
于是把
struct tim tv;
换成
struct timeval tv;即可。
0 0
- C/C++ error: storage size of ‘tv’ isn’t known错误解决方法
- recv_image.c:129 : error: storage size of 'rq' isn't known
- linux c TCP/IP 编译问题 error: storage size of ‘addrCriteria’ isn’t known解决办法
- linux c TCP/IP 编译问题 error: storage size of ‘addrCriteria’ isn’t known解决办法
- andorid编译报错serve_image.c:32:18: error: storage size of ‘hints’ isn’t known
- error: storage size of 'rq' isn't known 正解
- error storage size of 'pwbuf' isn't known
- error: storage size of ‘server_addr’ isn’t known
- error: storage size of ‘md_ctx’ isn’t known
- storage size of ‘oldact’ isn’t known
- storage size of 'a' isn't known
- storage size of ‘XXX’ isn’t known
- error: storage size of ‘rlimit_fsize’ isn’t known struct rlimit rlimit_fsize;
- error: storage size of ‘timeout’ isn’t known struct timeval timeout
- storage size of `seraddr' isn't known #include
- storage size of 'value' isn't known问题出现的可能原因
- storage size of 'value' isn't known问题出现的可能原因之一
- 编译jffs2报struct addrinfo storage size isn't known错误
- ubuntu_12.04下配置samba
- 黑马程序员_java基础加强学习笔记之(JDK1.5新特性)
- 【转】QTP10.0破解总结 .
- java 处理zip 压缩与解压的问题
- Jsp网络拓扑图--用java实现网络拓扑图
- C/C++ error: storage size of ‘tv’ isn’t known错误解决方法
- OSGi (一) 模块化和Java中模块化的弊病
- 关于rt3070wifi移植遇见问题求解
- 一个win32下的完成端口模式网络编程例子
- ognl表达式的简单用法
- 使用HttpURLConnection访问web页面
- cuda上使用printf函数
- 最为详尽的WPF类继承关系
- 9周项目2