From: Garrett Wollman <wollman@bimajority.org>
To: Douglas McIlroy <douglas.mcilroy@dartmouth.edu>
Cc: Alejandro Colomar <alx@kernel.org>,
linux-man <linux-man@vger.kernel.org>, kleink <kleink@netbsd.org>
Subject: Re: mkstemp(3)
Date: Thu, 7 May 2026 22:32:30 -0400 [thread overview]
Message-ID: <27133.19262.184587.893784@hergotha.csail.mit.edu> (raw)
In-Reply-To: <CAKH6PiWALYokfQtUdmhWPXJpyTSHKFAruZPd1qjG9W71om7DPg@mail.gmail.com>
<<On Thu, 7 May 2026 21:34:03 -0400, Douglas McIlroy <douglas.mcilroy@dartmouth.edu> said:
> Posix System Interfaces Section 2.2 tells me that I should #define
> _POSIX_C_SOURCE before #include <stdlib.h>. That fact is missing from
> Linux's man 3 mkstemp. Arguably the Posix description of mkstemp
> should mention it, too.
<div class="standards-lawyering">
Conveniently, POSIX.1-2008 removed mkstemp from the XSI option and
made it standard (shaded only CX and not XSI) so in 2008 and newer,
you don't have to define _XOPEN_SOURCE. You do have to set the
correct _POSIX_C_SOURCE value for the standard your implementation
confirms to, which currently means that you can only use C17 in
POSIX.1-2024 and cannot use C23 at all.
This may be the source of the confusion: for ISO C, "the
implementation" is the compiler, header files, and standard library,
so your C23 compiler ships with versions of those that meet the
requirements of the C23 standard. For POSIX on the other hand, "the
implementation" is the entire operating system, which must support one
and only one specific version of ISO C. It is up to your operating
system supplier (e.g. Linux distro packager) to build a <stdlib.h>
that meets the requirements of POSIX if they want to claim to be
POSIX-compliant. (Very likely they don't actually care about formal
compliance.)
An application that uses C23 features (or indeed that is compiled with
anything other than the POSIX.1-2024 `c17` utility) is not a
conforming POSIX application and its behavior is undefined. (Likewise
POSIX.1-2008 requires compilation with the `c99` utility, since that
standard is aligned to C99.)
</div>
-GAWollman
next prev parent reply other threads:[~2026-05-08 2:32 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-07 17:22 mkstemp(3) Douglas McIlroy
2026-05-07 20:23 ` mkstemp(3) Alejandro Colomar
2026-05-07 21:19 ` mkstemp(3) Garrett Wollman
2026-05-07 23:29 ` mkstemp(3) Alejandro Colomar
2026-05-08 1:34 ` mkstemp(3) Douglas McIlroy
2026-05-08 2:32 ` Garrett Wollman [this message]
2026-05-08 12:33 ` mkstemp(3) Alejandro Colomar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=27133.19262.184587.893784@hergotha.csail.mit.edu \
--to=wollman@bimajority.org \
--cc=alx@kernel.org \
--cc=douglas.mcilroy@dartmouth.edu \
--cc=kleink@netbsd.org \
--cc=linux-man@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox