I'm afraid these answers are nonsense. A program coming from the Win32 environment is using one of two possible setmode functions: either the Microsoft _setmode function documented in MSDN, or the Cygwin imitation of it called setmode.
This has nothing to do with the BSD setmode. It's a two-argument function which sets a file descriptor to either binary or text translation mode.
If your program expects this function, but you link to LibBSD, the program might link, but it is not correct.
GNU C 库不提供用于操作FILE *流或描述符的文本或二进制模式的接口,如果提供了,它也不会做任何事情,因为这两种模式是相同的。
在 Cygwinsetmode上需要 Cygwin函数的代码可能可以在 Unix 上不做任何事情而逃脱:也就是说:
#ifdef __CYGWIN__
setmode(fileno(my_stdio_stream), O_BINARY);
#elif _WIN32
_setmode(_fileno(my_stdio_stream), _O_BINARY);
#else
/* nothing on systems with no text-vs-binary mode */
#endif
Run Code Online (Sandbox Code Playgroud)