#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 ...
随机推荐
- C#高效新增数据到数据库(十万级别测试)
我们在对数据库进行新增数据时,怎么能把速度提到最快,时间缩到最短呢?下面针对三种方法进行比较 新增 逐条新增数据模式 Stopwatch s2 = new Stopwatch(); s2.Start( ...
- 单独安装VS2012装mono for android
直接安装个SQL Server2012,然后就可以单独安装VS2012 来用mono for android了.如果不想装,那就装以下这些东西. 广州-PC286() 11:05:28 和 x86 ...
- ToolkitScriptManager vs. ScriptManager 关于“只能向页面中添加 ScriptManager 的一个实例”讨论
在使用ASP.NET设计AJAX功能网页时,需要首先声明ToolkitScriptManager或者ScriptManager控件,这些全局的脚本核心控制,然后才能使用众多的AJAX控件.如果没有创建 ...
- windows下简单配置apache
不得不做个笔记,不然每次配置都记不清楚... 详细的配置朋友这边写的很好.地址 # 对 PHP 4 LoadModule php4_module "c:/php/php4apache2.dl ...
- linux mint 19安装 kvm 软件包
1 我的处理器是2700x 首先安装cpu检测 sudo apt-get install cpu-checker 2 查看cpu内核 egrep -c '(vmx|svm)' /proc/cpuinf ...
- C#(winform)设置窗口置顶
只要设置窗体的TopMost属性即可: registerForm.TopMost = true;
- a+b+c的N次方展开
今天在给儿子看笔记本上的照片的时候,偶然发现了2009年手绘的一张a+b+c的N次方展开图,故写下面的博客以记之,为年轻时代的我点个赞! 20年前的我,一个充满激情的且富有专注力的数学发烧友! 10年 ...
- Uboot流程分析
1. uboot的配置分析 1).配置入口分析 首先分析配置: 从make mx6dl_sabresd_android_config可知配置项,搜索Makefile: mx6solo_sabresd_ ...
- Html-完整表格
表头th 特殊的单元格:加粗.居中 它的用户是取代td的位置即可 <table border="2"> <tr> <th>姓名</th&g ...
- PL/SQL之存储过程和触发器实例
1.Oracle存储过程实例 /*不带任何参数存储过程(输出系统日期)*/ CREATE OR REPLACE PROCEDURE output_date IS BEGIN DBMS_OUTPUT.P ...