BZ#10254: Explain additional fopen parameters

Kalle Olavi Niemitalo kon@iki.fi
Mon Apr 9 12:41:00 GMT 2012


Andreas Jaeger <aj@suse.com> writes:

> +@item x
> +Insist on creating a new file---if a file @var{filename} already
> +exists, @code{fopen} fails rather than opening it.  If you use
> +@samp{x} you are guaranteed that you will not clobber an existing
> +file.  This is equivalent to the @code{O_EXCL} option to the
> +@code{open} function (@pxref{Opening and Closing Files})

This meaning of "x" is also in the N1570 draft of C11.  Unless
the ratified C11 standard differs in this, I think the glibc
manual should mention that "x" is not solely a glibc extension,
and that portable programs using "x" should make it the last
character of the string.



More information about the Libc-alpha mailing list