sys/time.h 和 time.h
今天在燕麦工作第二天。看荣哥给我的程序,发现程序里面用的延时跟我以前使用的不同。导入两个头文件,然后用函数来获得时间。关于这个函数特别查来一下。
time.h 是ISO C99 标准日期头文件。
sys/time.h 是Linux系统的日期头文件。
sys/time.h 通常会包含include "time.h"
编写的代码如果与平台无关的,则需要在代码里 #include "time.h" 但这样使用time_t等数据结构的话需要手动
#define __need_time_t #define __need_timespec
gettimeofday() 函数在sys/time.h 内。
定义 : int gettimeofday(struct timeval * tv, struct timezone * tz);
函数说明:gettimeofday()会把目前的时间用__restrict结构体返回,当地时区的信息则放到tz的结构中国。。
结构体:
1. timeval
struct timeval
{
long tv_sec; /* 秒 */
long tv_usec; /* 微秒 */
};
2. timezone
struct timezone{ int tz_minuteswest;/* 和 greenwich 时间差来多少分钟*/ int tz_dsttime;/*type of DST correction */}
3. 在 gettimeofday()函数中tv 或者 tz 都可以为空。 如果为空就不返回其对应的结构体。
4. 函数在执行成功后返回0, 失败后返回-1, 错误代码存在于errno 中。
sys/time.h 和 time.h的更多相关文章
- cxx11emu.h 和 logprint.h
cxx11emu.h 和 logprint.h /* Start of cxx11emu.h */ #ifndef STDBP_CXX11EMU_H_ #define STDBP_CXX11EMU_H ...
- 单片机中用c编程时头文件reg51.h及reg52.h解析
单片机中用c编程时头文件reg51.h及reg52.h解析 我们在用c语言编程是往往第一行就是reg51.h或者其他的自定义头文件,我们怎么样来理解呢? 1)“文件包含”处理. 程序的第一行是一个“文 ...
- windows.h和winsock2.h包含顺序问题(转)
windows.h和winsock2.h有类型重定义我是知道的,本来就一个库来说没问题,把winsock2放到windows.h前或先定义WIN32_LEAN_AND_MEAN都能解决问题但现的出了问 ...
- VS2013使用winsock.h和winsock2.h发生冲突后的终极解决方法
问题:彻底无语了,不小心某个文件包含了windows.h头文件,而windows.h文件里面包含着winsock.h文件, 如果你下次使用winsock2.h文件时,位置不对,然后编译器会给你一大堆重 ...
- [转]rpcndr.h和wtypes.h冲突Bug的解决方案
[转]rpcndr.h和wtypes.h冲突Bug的解决方案 http://blog.csdn.net/tzwh_86/article/details/9495133 rpcndr.h和wtypes. ...
- 已经包含了#include <atlcom.h> #include <comutil.h>还是报错
在WTL工程的.h中 #include <atlbase.h>#include <atlcom.h>#include <atlcomcli.h>#include & ...
- c语言string.h和memory.h某些函数重复问题
在C语言中,为了使用memset()函数,你是选择#include <string.h>还是<memory.h>?两个都可以,如何选择? <string.h>,标准 ...
- 解决VS2010中winsock.h与winsock2.h冲突(重复定义)——转载
解决VS2010中winsock.h与winsock2.h冲突(重复定义)——转载 当这两个头文件顺序颠倒时,编译会出现许多莫名其妙的错误,错误如下: 1>…\include\ws2def.h( ...
- 清北学堂入学测试P4751 H’s problem(h)
P4751 H’s problem(h) 时间: 1000ms / 空间: 655360KiB / Java类名: Main 背景 冬令营入学测试 描述 小H是一个喜欢逛街的女孩子,但是由于上了大学 ...
- Linux程序设计中的curses.h编译报错,无法找到curses.h和ncurses.h
源程序screen.c如下: #include <stdio.h> #include <term.h> #include <curses.h> #include & ...
随机推荐
- JS正则表达式验证是否为11位有效手机号码
function isPoneAvailable($poneInput) { var myreg=/^[1][3,4,5,7,8][0-9]{9}$/; if (!myreg.test($poneIn ...
- jq以固定开头的class属性的名称
$("div[class^='pick']").css({'border-color':'#000000'}); div [class^="aaa"]
- Activity(活动)
- [转载]linux中sed的用法
转自:http://www.cnblogs.com/emanlee/archive/2013/09/07/3307642.html sed命令行格式为: sed [-nefri] ‘ ...
- Convert 实现 pdf 和图片格式互转
pdf 转换为图片 (注意:pdf 默认转换的是透明背景,如果转为jpg格式必须添加背景色.-background white -flatten) convert -background white ...
- PropertyPlaceholderConfigurer
PropertyPlaceholderConfigurer Spirng在生命周期里关于Bean的处理大概可以分为下面几步: 加载 Bean 定义(从xml或者从@Import等) 处理 BeanFa ...
- python连接Linux服务器
import paramikoimport os #当前脚本路径CUR_PATH = os.path.dirname(__file__) #服务器ipHost=''Port=22#登录用户名Usern ...
- 带token的get和post方法
GET和POST传值失败,多半是传输的字符串和URL的事 public static string ExcuteGetToken(string serviceUrl, string ReqInfo, ...
- AX_Args
Args args; FormRun formRun; ; args = new Args(); args.name(formstr(FormName)); args.caller(); args.r ...
- Flex 得到一个对象的所有属性
var obj:Object =..... ///需要处理的对象 fieldname:Array = ObjectUtil.getClassInfo(obj)["properties&quo ...