在 Unix 上 write 函数需要 unistd.h,那么 windows 呢?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5684679/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
write function requires unistd.h on Unix, what about windows?
提问by stockoverflow
I've changed from a linux computer to a windows and I'm having trouble compiling my code because these two OS don't share the same header files.
我已经从 linux 计算机更改为 windows 并且我在编译代码时遇到了麻烦,因为这两个操作系统不共享相同的头文件。
Since the unistd.h is not obviously included, Visual C doesn't know what read()
, write()
, close()
, socklen_t()
and bzero()
functions are. Can anyone help me with this?
由于unistd.h中不包含明显,视觉C不知道是什么read()
,write()
,close()
,socklen_t()
和bzero()
功能。谁能帮我这个?
I've googled this: Is there a replacement for unistd.h for Windows (Visual C)?
我在谷歌上搜索过这个:Windows (Visual C) 是否有 unistd.h 的替代品?
I have no idea how unistd.h works, nor do I know how to code my own. Can someone please link me to one?
我不知道 unistd.h 是如何工作的,也不知道如何编写自己的代码。有人可以将我链接到一个吗?
采纳答案by Rafe Kettler
回答by Jerry Coffin
read
, write
and close
are in <io.h>
, just like they traditionally were on Unix.
read
,write
和close
在 中<io.h>
,就像它们传统上在 Unix 上一样。
Offhand, I don't know of a bzero
being included on Windows at all -- if you care at all about portability, you normally want to use memset
instead.
顺便说一句,我根本不知道bzero
Windows 中是否包含一个工具——如果您完全关心可移植性,您通常想memset
改用它。
socklen_t
isn't normally used on Windows -- most things that would be socklen_t
on Unix use either size_t
or int
on Windows (socklen_t
on Unix is currently another reference to the same underlying type as size_t
, added in case it might be useful someday -- aka, a solution in search of a problem).
socklen_t
通常不使用Windows上-大多数事情,这将是socklen_t
在Unix兼用size_t
或int
在Windows(socklen_t
在Unix上是目前的另一个引用相同的基础类型size_t
,在增加的情况下它可能是有益的一天-又名,在溶液中搜索问题)。