Search code examples
ccompiler-errorscygwin

No sys/sendfile.h on Cygwin?


I'm trying to compile some C code on Cygwin which needs the sendfile.h. When I try to compile, it gives me

fatal error: sys/sendfile.h: No such file or directory
compilation terminated.

How do I solve this? Will I have to move to a linux platform? I have gcc4.5 installed on Cygwin.


Solution

  • Like the comment mentioned, sendfile is not POSIX, however, from the man page of 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.

    Which means it's basically a read() followed by a write(), so it would be relatively easy to implement it yourself.