the usage of "mkstemp" requires std=c... or std=gnu.. ?

Brian Inglis Brian.Inglis@SystematicSW.ab.ca
Sun Oct 19 16:41:39 GMT 2025


On 2025-10-18 13:50, Marco Atzeri via Cygwin wrote:
> from
> https://pubs.opengroup.org/onlinepubs/9799919799/functions/mkdtemp.html
> Issue 7
>      Austin Group Interpretation 1003.1-2001 #143 is applied.
>      SD5-XSH-ERN-168 is applied, clarifying file permissions upon creation.
>      The mkstemp() function is moved from the XSI option to the Base.
> I would expect --std=c++-20 should be enough, but
> currently --std=gnu++-20 is required to build latest
> version of libheif

"Issue 8
Austin Group Defect 251 is applied, encouraging implementations to disallow the 
creation of filenames containing any bytes that have the encoded value of a 
<newline> character.
Austin Group Defects 411, 1318, and 1350 are applied, adding mkostemp().
Austin Group Defect 652 is applied, adding the [EINVAL] error for mkstemp().
Austin Group Defect 1734 is applied, replacing the error conditions specified 
only for mkdtemp() with a reference to mkdir()."

Those functions are not in Standard C or draft C 203Y (below);
mkstemp is POSIX from 200112 and no longer in XSI;
mkostemp/s requires || __POSIX_VISIBLE >= 202405 (from _POSIX_C_SOURCE >= 
202405L) - in newlib, and also in glibc below;
all require POSIX features enabled by some definition;
from Linux 6.15 mkstemp(3):

"Feature Test Macro Requirements for glibc (see feature_test_macros(7)):

	mkstemp():
	    _XOPEN_SOURCE >= 500
		|| /* glibc >= 2.12: */ _POSIX_C_SOURCE >= 200809L
		|| /* glibc <= 2.19: */ _SVID_SOURCE || _BSD_SOURCE

	mkostemp():
	    _GNU_SOURCE"
q
$ grep -HwC1 'mk\(d\|os\|s\)temp' ~/src/standard-docs/C/N3220-C2023-FDIS.txt
$ grep -HwC1 'mk\(d\|os\|s\)temp' ~/src/standard-docs/C/N3685-C203Y-WD.txt
$ grep -HwC1 'mk\(d\|os\|s\)temp' /usr/include/stdlib.h
/usr/include/stdlib.h-#if __BSD_VISIBLE || __POSIX_VISIBLE >= 200809
/usr/include/stdlib.h:char *	mkdtemp (char *);
/usr/include/stdlib.h-#endif
/usr/include/stdlib.h-#if __GNU_VISIBLE
/usr/include/stdlib.h:int	mkostemp (char *, int);
/usr/include/stdlib.h-int	mkostemps (char *, int, int);
--
/usr/include/stdlib.h-#if __MISC_VISIBLE || __POSIX_VISIBLE >= 200112 || 
__XSI_VISIBLE >= 4
/usr/include/stdlib.h:int	mkstemp (char *);
/usr/include/stdlib.h-#endif

[I use C 203Y because there is almost no chance another C Standard will be 
released this decade; especially as current POSIX has not yet been adopted by 
ISO, as it has to be passed through the IEEE Partner Standards Development Org 
(PSDO) FDIS "fast-track" process with Edition 2 ballot close on 2026-01-24.]

-- 
Take care. Thanks, Brian Inglis              Calgary, Alberta, Canada

La perfection est atteinte                   Perfection is achieved
non pas lorsqu'il n'y a plus rien à ajouter  not when there is no more to add
mais lorsqu'il n'y a plus rien à retrancher  but when there is no more to cut
                                 -- Antoine de Saint-Exupéry


More information about the Cygwin mailing list