我正在尝试在需要 sendfile.h 的 Cygwin 上编译一些 C 代码。当我尝试编译时,它给了我
fatal error: sys/sendfile.h: No such file or directory
compilation terminated.
我该如何解决这个问题?我必须迁移到 Linux 平台吗?我在 Cygwin 上安装了 gcc4.5。
最佳答案
就像提到的评论一样,sendfile
不是 POSIX,但是,从
sendfile(2)
sendfile() copies data between one file descriptor and another. Because this copying is done within the kernel, sendfile() is more efficient than the combination of read(2) and write(2), which would require transferring data to and from user space.
这意味着它基本上是一个 read()
后跟一个 write()
,因此您自己实现它会相对容易。
关于c - Cygwin 上没有 sys/sendfile.h?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13182743/