sys/sendfile.h 未找到 GCC
我使用的是Mac OS 10.6.7,
当我购买Mac时gcc编译器已经存在。 但是当我尝试包含 sys/sendfile.h 时 #include
它会抛出一个错误
sys/sendfile.h: No such file or directory.
,但是这个程序在 ubuntu GCC 编译器中可以正常工作。知道如何解决这个问题吗?
I am using Mac OS 10.6.7,
The gcc compiler was already there when I bought Mac.
but when I try to include sys/sendfile.h#include<sys/sendfile.h>
it throws an error
sys/sendfile.h: No such file or directory.
But this program works correctly in ubuntu GCC Compiler. Any idea how to fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
sendfile() 最终是一种内核功能,而不是库或编译器,引用 linux 手册页,“其他 Unix 系统以不同的语义和原型实现 sendfile()。它不应该在可移植程序中使用。”
这里曾经有一个指向适用的 OSX/Darwin 手册页的 sendfile 的链接,但 Apple 不断移动他们的文档,因此您必须自己找到它。
事实上,linux 手册页警告是准确的 - 原型不同:
OSX:
Linux:
因此您需要重新编写一些内容。
osx 包含在该手册页上,但为了完整性:
sendfile() is ultimately a kernel capability not a library or compiler one, and to quote the linux manpage, "Other Unix systems implement sendfile() with different semantics and prototypes. It should not be used in portable programs."
There used to be a link to the applicable OSX/Darwin manpage for sendfile here, but Apple keeps moving their documentation, so you'll have to find that on your own.
And indeed the linux manpage warning is accurate - the prototypes are different:
OSX:
Linux:
So you will have some re-writing to do.
The osx includes are on that man page, but for completeness:
根据 Linux 手册页:
我不确定 OSX,但似乎你必须自己挖掘一下才能找到它。
According to the Linux manual page:
I'm not sure about OSX, but it seems you have to do a little digging yourself to find it.
您在寻找
sendfile(2)
吗?如果是这样,它不在 sys/sendfile.h 中:OS X 开发人员库 指出您应该包含这些:
Are you looking for
sendfile(2)
? If so, it's not insys/sendfile.h
:The OS X Developer Library states you should include these:
在 OSX 上,sendfile 在 socket.h 中定义。所以你需要包含socket.h而不是sys/sendfile.h
On OSX sendfile is defined in socket.h. So you need to include socket.h instead of sys/sendfile.h