#include <unistd.h> 的作用
原文: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> 的作用的更多相关文章
- #include <sys/stat.h>的作用
#include <sys/stat.h> 文件状态, 是unix/linux系统定义文件状态所在的伪标准头文件. 含有类型与函数: dev_t st_dev Device ...
- /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 ...
- #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使用详解(精髓) ...
- 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 ...
- [C++]Linux之头文件sys/types.h[/usr/include/sys]
1.查找<sys/types.h>文件 一般地,Linux的C头文件<sys/types.h>路径在如题的途径:/usr/include/sys下,然而博主[Linux For ...
- #include <sys/socket.h>找不到头文件
ubuntu下socket编程涉及到头文件sys/socket.h 和sys/types.h.我是用的codeblocks编辑器,当我想查看socket,h头文件时编辑器提示找不到头文件. 我就想可能 ...
- sys/types.h fcntl.h unistd.h sys/stat.h
sys/types.h 是Unix/Linux系统的基本系统数据类型的头文件,含有size_t,time_t,pid_t等类型. 在应用程序源文件中包含 <sys/types.h> 以访问 ...
- [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 ...
- 用ioctl获取无线网络信息 /usr//include/linux/wireless.h
1.UNIX Network Programming环境搭建 Unix NetWork Programming――环境搭建(解决unp.h等源码编译问题) http://blog.csdn.net/a ...
- stdafx.h的作用以及原理
stdafx.h VC工程里面经常见到stdafx.h这个头文件,以前也没有特别注意,但是这个文件用不好经常会出错,所以就GOOGLE了一下,总算是弄清楚了... stdafx的英文全称为:Stand ...
随机推荐
- Ubuntu16.04安装视觉SLAM环境(DBow3)
1.从Github上现在DBow3词袋模型库 git clone https://github.com/rmsalinas/DBow3.git 2.开始安装DBow3库,进入DBow3目录 mkdir ...
- request.getSession(true/false)的区别
javax.servlet.http.HttpServletRequest接口有两个方法:getSession(boolean)和getSession(). 具体什么区别,跟踪源码分析下,先摆出结论: ...
- CentOS7 安装 Visual Code
官网下载 rpm 安装文件 运行 rpm -ivh 试一下 sudo rpm -ivh xxx.rpm 有可能弹出提出:libxx.so() need by xxxrpm ,反正意思是缺组件,去下载安 ...
- 【算法笔记】B1053 住房空置率
看了半天发现是题目理解错了,可能空置的里面观察期超过D则判定空置,而不是用电量低于e的天数超过D. code #include <bits/stdc++.h> using namespac ...
- 【App性能分析】:tracelog分析法
tracelog可以记录每个OpenGL函数调用的消耗时间,所以很多时候用来作performance分析.目前只支持安卓4.1以上的版本设备 1,目前Android Device Monitor最新的 ...
- (转)DB2下载地址总结
原文:https://blog.csdn.net/huozengguang/article/details/58602910 DB2 v8.2,v9.1,v9.5,v9.7下载地址 下列都是完全版包含 ...
- jquery mobile 动态加载标签时,无法正常展示样式
原因 在chrome中审查元素,发现其增加了很多没有直接写在页面上的标签和样式.页面标签首先经过jquery.mobile-1.4.5.min.js的处理,添加了许多标签,然后再用css布局 解决方案 ...
- JavaScript数据结构-17.图结构
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- Debugging Ruby in VS Code
原文 https://dev.to/dnamsons/ruby-debugging-in-vscode-3bkj https://github.com/Microsoft/vscode-recipe ...
- erlang尾递归练习
1 %%计算链表长度尾递归实现 2 lez(N) -> lez(N, 0). 3 4 lez([], Acc) -> Acc; 5 lez([_ | T], Acc) -> lez( ...