This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC] Suggested ways to remove the need for xm-go32.h


Corinna Vinschen <vinschen@redhat.com> writes:

> On Sep 24 12:46, Eli Zaretskii wrote:
> > > Out of curiousity is O_BINARY mandated by ISO C?  I suspect not.
> > 
> > O_BINARY is a Posix thing (ANSI C doesn't know about `open' at all),
> > so ISO C has nothing to say about it.  But even if you look at the
> > latest Posix (well, the draft I have here), you will not find O_BINARY
> > there.  So Posix systems are not allowed to distinguish between text
> > and binary files.
> 
> That's nothing GDB should be concerned of, probably, but that's definitely
> a leak in the definitions.  How much sense does it make to allow "b" in
> fopen but no equivalent in the low-level interface :-(

POSIX and ISO C are different standards.

In a POSIX system there can be no difference between text and binary
files.  So there is no reason for POSIX to specify O_BINARY.

ISO C permits distinctions between text and binary files, since ISO C
is used on non-POSIX systems such as Windows.  So ISO C specifies that
'b' is permitted in fopen and related calls.

POSIX supports but does not require ISO C.  When ISO C is used on
POSIX, fopen and friends ignore the 'b'.

O_BINARY exists because systems like Windows like to have almost-POSIX
interfaces.  O_BINARY was invented so that such systems could continue
to distinguish text and binary files in the almost-POSIX open call.

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]