Re: Comparing binary files with Diff 3.2 compiled with MinGW

Bruno Haible <[email protected]>
Newsgroups gmane.comp.lib.gnulib.bugs,gmane.comp.gnu.utils.bugs
Message-ID <4196305.pfpNaAzPQJ@linuix>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.