原文:http://blog.csdn.net/ybsun2010/article/details/24832113

由字面意思,unistd.h是unix std的意思,是POSIX标准定义的unix类系统定义符号常量的头文件,

包含了许多UNIX系统服务的函数原型,例如read函数、write函数和getpid函数。

参考自 http://hi.baidu.com/w_dalu/item/e8d29860374ae02369105b11

unistd.h在unix中类似于window中的windows.h!

#ifdef WIN32
#include <windows.h>
#else
#include <unistd.h>
#endif

unistd.h含有的常量与函数:

ssize_t      read(int, void *, size_t); // 读取文件使用
int          unlink(const char *);
ssize_t      write(int, const void *, size_t); // 写文件
int          usleep(useconds_t); // 进程休眠,单位为微妙
unsigned     sleep(unsigned); // 进程休眠,单位为秒

int          access(const char *, int); // 获取文件的权限
unsigned     alarm(unsigned);
int          chdir(const char *);
int          chown(const char *, uid_t, gid_t);
int          close(int); // 关闭文件
size_t       confstr(int, char *, size_t);
void        _exit(int);
pid_t        fork(void);

NULL           // Null pointer
SEEK_CUR    // Set file offset to current plus offset.
SEEK_END    // Set file offset to EOF plus offset.
SEEK_SET    // Set file offset to offset.

许多在Linux下开发的C程序都需要头文件unistd.h,但VC中没有个头文件,
所以用VC编译总是报错。把下面的内容保存为unistd.h,可以解决这个问题。
/** This file is part of the Mingw32 package.
* unistd.h maps (roughly) to io.h
*/

#ifndef _UNISTD_H
#define _UNISTD_H
#include <io.h>
#include <process.h>
#endif /* _UNISTD_H */

#include <unistd.h> 的作用的更多相关文章

  1. #include <sys/stat.h>的作用

    #include <sys/stat.h> 文件状态, 是unix/linux系统定义文件状态所在的伪标准头文件. 含有类型与函数: dev_t     st_dev     Device ...

  2. /usr/include/sys/types.h:62: error: conflicting types for ‘dev_t’

    /usr/include/sys/types.h:62: error: conflicting types for ‘dev_t’/usr/include/linux/types.h:13: erro ...

  3. #include <sys/epoll.h> epoll - I/O event notification facility 服务器端 epoll(7) - Linux manual page http://www.man7.org/linux/man-pages/man7/epoll.7.html

    epoll使用详解(精髓) - Boblim - 博客园 https://www.cnblogs.com/fnlingnzb-learner/p/5835573.html epoll使用详解(精髓) ...

  4. Cygwin环境编译/usr/include/sys/_types.h:72:20: 致命错误:stddef.h:can not found

    环境介绍: win7_x64 +Cygwin64 gcc :4.8.2 g++:4.8.1 编译 c++的helloworld.cpp 一直失败! 代码如下: #include <iostrea ...

  5. [C++]Linux之头文件sys/types.h[/usr/include/sys]

    1.查找<sys/types.h>文件 一般地,Linux的C头文件<sys/types.h>路径在如题的途径:/usr/include/sys下,然而博主[Linux For ...

  6. #include &lt;sys/socket.h&gt;找不到头文件

    ubuntu下socket编程涉及到头文件sys/socket.h 和sys/types.h.我是用的codeblocks编辑器,当我想查看socket,h头文件时编辑器提示找不到头文件. 我就想可能 ...

  7. sys/types.h fcntl.h unistd.h sys/stat.h

    sys/types.h 是Unix/Linux系统的基本系统数据类型的头文件,含有size_t,time_t,pid_t等类型. 在应用程序源文件中包含 <sys/types.h> 以访问 ...

  8. [opencv3.2cmake error ] sys/videoio.h no such file or directories

    I don't have /usr/include/sys/videoio.h at all Before that , I have ipp download question. So I down ...

  9. 用ioctl获取无线网络信息 /usr//include/linux/wireless.h

    1.UNIX Network Programming环境搭建 Unix NetWork Programming――环境搭建(解决unp.h等源码编译问题) http://blog.csdn.net/a ...

  10. stdafx.h的作用以及原理

    stdafx.h VC工程里面经常见到stdafx.h这个头文件,以前也没有特别注意,但是这个文件用不好经常会出错,所以就GOOGLE了一下,总算是弄清楚了... stdafx的英文全称为:Stand ...

随机推荐

  1. Python flask Reason: image not found libmysqlclient.21.dylib

    Python flask Reason: image not found libmysqlclient.21.dylib 折腾了半个下午,在这里找到了答案,在此记录一下,以免后人躺坑 错误提示: Im ...

  2. Zynq-7000 FreeRTOS(二)中断:串口Uart中断

    总结Zynq-7000器件的PS上的串口中断,为FreeRTOS中断实验做准备.

  3. 工具软件推荐——GifCam

    博文里面的动态gif图片都是使用这款软件录制的,可以选择帧率,清晰度,并且编辑每一帧的图片,非常好用,特此推荐~ 注意: GifCam 是一款免费绿色的软件. 大家尽量在官方下载 下载地址. 最新的版 ...

  4. OpenERP 中的on_change方法总结

    1.xml中应为on_change=""的形式 2.py文件中 self,cr,uid,ids为必备参数,后面的参数根据xml文件中的参数的数量而定 3.return的是一个字典, ...

  5. [问题解决]Android7.0上PopupWindow的showAsDropDown位置问题

    [问题解决]Android7.0上PopupWindow的showAsDropDown位置问题 /** * Created by diql on 2017/02/16. */ 问题说明 我的popup ...

  6. win10+GTX1080+Tensorflow1.6安装

    安装参考网站:http://blog.csdn.net/lp654063449/article/details/79340655 依照安装目录依次安装,所需安装包均已下载,在最后的一步中,打开cuda ...

  7. SQL语句实现不存在即插入,存在则increase某字段的功能insert into … on duplicate key update

    前提条件:必须是唯一主键: CREATE UNIQUE INDEX idx_vote_object ON test_customers_vote (`vote_object`, `vote_objec ...

  8. 一文带你入门图像分析,成为AI专家不是梦!

    欢迎大家前往腾讯云+社区,获取更多腾讯海量技术实践干货哦~ 本文由腾讯云AI中心发表于云+社区专栏 腾讯云高级研究员讲述,从成像到图像分析如何入门 文︱冀永楠 "AI来了"邀请到我 ...

  9. JS数组和函数 小记

    数组 JS中的数组来自window,是一个全局的对象,typeof的值是'object'. 创建数组: 1.Array(3):当只传一个值的时候,会生成一个长度为该数值的空数组. 2.Array(3, ...

  10. mysql索引对单表查询的影响

    索引被用来快速找出在一个列上用一特定值的行.没有索引,MySQL不得不首先以第一条记录开始并然后读完整个表直到它找出相关的行.表越大,花费时间越多. 如果表对于查询的列有一个索引,MySQL能快速到达 ...