Mail Archives: djgpp/2009/04/04/18:45:58
"Eli Zaretskii" <eliz AT gnu DOT org> wrote in message
news:83bprccygw DOT fsf AT gnu DOT org...
> > freopen() is supposed to implement all functionality of fopen(), which
> > includes opening the redirected-to-file as binary.
>
> And it does, as long as you know the name of that file.
>
Then, what is DJGPP's filename to use for stdout as the first parameter of
freopen()? NULL? I tried that too. It failed. It continued to output to
stdout in text mode.
After looking at the spec., I'm asking how to go about using freopen() to do
what is mentioned in ISO C 7.19.5.4 sub 3:
"If filename is a NULL pointer, the freopen function attempts to change the
mode of the stream to that specified by mode, as if the name of the file
currently associated with the stream had been used. It is
implementation-defined which changes of mode are permitted (if any), and
under what circumstances."
How do I change the mode of stdout to binary, just as in the setmode call,
by using freopen()?... NULL doesn't work. Is this functionality
implemented?
Previously,
> > First, is there an equivalent to this in ANSI C?
>
> No. ANSI C says that everything about stdin and stdout is
> implementation-defined, IIRC.
I think the correct answer to that question is: Yes. ANSI C specifies an
equivalent. The ANSI C equivalent is to use NULL as the first parameter to
freopen(). Sub 3 says freopen() is _required_ to *attempt* to change the
mode regardless of whether it is supported or not. Which modes are actually
*permitted* by an implementation are implementation-defined. I already know
that it seems that it isn't implemented. It is implemented somehow, by some
method, using freopen() that I'm not recognizing? Given that the setmode()
to binary for stdout for works for DJGPP, I don't understand why this
wouldn't be implemented as part of freopen() too since it is mentioned in
the spec....
Rod Pemberton
- Raw text -