Microsoft recommends using the _s variety of C runtime functions: https://docs.microsoft.com/en-us/cpp/c-runtime-library/security-features-in-the-crt These are well-supported in mingw64, but the headers need to be enabled by passing `--enable-secure-api` to the `./configure` at compile time. This has the affect of sticking MINGW_HAS_SECURE_API into mingw.h: AC_MSG_CHECKING([whether to enable the secure API]) AC_ARG_ENABLE([secure-api], [AS_HELP_STRING([--enable-secure-api], [Expose secure API prototypes])], [], [enable_secure_api=no]) AC_MSG_RESULT([$enable_secure_api]) AS_VAR_IF([enable_secure_api],[yes], [MINGW_HAS_SECURE_API="#define MINGW_HAS_SECURE_API 1"], [MINGW_HAS_SECURE_API=""]) AC_SUBST([MINGW_HAS_SECURE_API]) Other mingw64 toolchains enable this too, for example the ones available from http://musl.cc/ .
The bug has been closed via the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=25efe91bae6323a6ab9e853132d847274e53f7ef commit 25efe91bae6323a6ab9e853132d847274e53f7ef Author: Sergei Trofimovich <slyfox@gentoo.org> AuthorDate: 2019-08-13 07:09:26 +0000 Commit: Sergei Trofimovich <slyfox@gentoo.org> CommitDate: 2019-08-13 07:10:24 +0000 dev-util/mingw64-runtime: add USE=+secure-api, bug #691980 Expose *_s() family of functions by default from headers. Reported-by: Jason A. Donenfeld Closes: https://bugs.gentoo.org/691980 Package-Manager: Portage-2.3.71, Repoman-2.3.17 Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org> dev-util/mingw64-runtime/metadata.xml | 1 + .../mingw64-runtime-6.0.0-r2.ebuild | 113 +++++++++++++++++++++ 2 files changed, 114 insertions(+)