sys/sendfile.h 未找到 GCC

发布于 2024-12-18 01:37:22 字数 266 浏览 5 评论 0原文

我使用的是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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

久夏青 2024-12-25 01:37:22

sendfile() 最终是一种内核功能,而不是库或编译器,引用 linux 手册页,“其他 Unix 系统以不同的语义和原型实现 sendfile()。它不应该在可移植程序中使用。”

这里曾经有一个指向适用的 OSX/Darwin 手册页的 sendfile 的链接,但 Apple 不断移动他们的文档,因此您必须自己找到它。

事实上,linux 手册页警告是准确的 - 原型不同:

OSX:

int sendfile(int fd, int s, off_t offset, off_t *len, struct sf_hdtr *hdtr, int flags);

Linux:

ssize_t sendfile(int out_fd, int in_fd, off_t *offset, size_t count);

因此您需要重新编写一些内容。

osx 包含在该手册页上,但为了完整性:

#include <sys/types.h>
#include <sys/socket.h>
#include <sys/uio.h>

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:

int sendfile(int fd, int s, off_t offset, off_t *len, struct sf_hdtr *hdtr, int flags);

Linux:

ssize_t sendfile(int out_fd, int in_fd, off_t *offset, size_t count);

So you will have some re-writing to do.

The osx includes are on that man page, but for completeness:

#include <sys/types.h>
#include <sys/socket.h>
#include <sys/uio.h>
策马西风 2024-12-25 01:37:22

根据 Linux 手册页

POSIX.1-2001 或其他标准中未指定。

其他 UNIX 系统以不同的语义和原型实现 sendfile()。它不应该在可移植程序中使用。

我不确定 OSX,但似乎你必须自己挖掘一下才能找到它。

According to the Linux manual page:

Not specified in POSIX.1-2001, or other standards.

Other UNIX systems implement sendfile() with different semantics and prototypes. It should not be used in portable programs.

I'm not sure about OSX, but it seems you have to do a little digging yourself to find it.

小嗲 2024-12-25 01:37:22

您在寻找 sendfile(2) 吗?如果是这样,它不在 sys/sendfile.h 中:

OS X 开发人员库 指出您应该包含这些:

 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/uio.h>

Are you looking for sendfile(2)? If so, it's not in sys/sendfile.h:

The OS X Developer Library states you should include these:

 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/uio.h>
梦太阳 2024-12-25 01:37:22

在 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文