Eli Zaretskii wrote:
> > I would suggest to use a function
> >
> > int setmode (int fd, int o_mode);
> >
> > exactly like in Cygwin, so that no code is needed on Cygwin.
>
> You mean, us it directly, not through a macro?
I meant, through a macro or a function, depending on what's easiest on each
platform.
> If I use setmode, then #ifdef's are necessary.
I meant that setmode should be defined, either as a function or as a
function-like macro, on all platforms.
> But then why does gnulib provide SET_BINARY as a macro?
SET_BINARY is a simpler-to-use macro for the simpler cases. Many GNU
programs do things like this:
if (strcmp (filename, "-") == 0 || strcmp (filename, "/dev/stdin") == 0)
{
fp = stdin;
SET_BINARY (fileno (fp));
}
else
{
fp = fopen (filename, "rb");
...
}
> Using UNSET_BINARY allowed me to avoid any #ifdef's in the application
> code.
I prefer a macro or function that takes an additional boolean argument
to another macro.
Bruno