Geo*_*aul 5 c c++ networking gcc osx-snow-leopard
我使用的是 Mac OS 10.6.7,
当我购买 Mac 时,gcc 编译器已经在那里了。但是当我尝试包含 sys/sendfile.h
#include<sys/sendfile.h>
它抛出一个错误
sys/sendfile.h: No such file or directory.
Run Code Online (Sandbox Code Playgroud)
但是这个程序在 ubuntu GCC Compiler 中可以正常工作。知道如何解决这个问题吗?
sendfile() 最终是一种内核功能,而不是库或编译器功能,引用 linux 联机帮助页,“其他 Unix 系统使用不同的语义和原型实现 sendfile()。它不应该用于可移植程序。”
曾经有一个指向适用于 sendfile 的 OSX/Darwin 联机帮助页的链接,但 Apple 一直在移动他们的文档,因此您必须自己找到它。
确实 linux 联机帮助页警告是准确的 -原型不同:
操作系统:
int sendfile(int fd, int s, off_t offset, off_t *len, struct sf_hdtr *hdtr, int flags);
Run Code Online (Sandbox Code Playgroud)
Linux:
ssize_t sendfile(int out_fd, int in_fd, off_t *offset, size_t count);
Run Code Online (Sandbox Code Playgroud)
因此,您将需要重新编写一些内容。
osx 包含在该手册页上,但为了完整起见:
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/uio.h>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8579 次 |
| 最近记录: |