[vlc-devel] [PATCH] contrib: nfs: Patch win32_compat.h to not override snprintf
Martin Storsjö
martin at martin.st
Sat Mar 13 11:34:49 UTC 2021
Mingw toolchains always provide snprintf, and modern MSVC versions
do too.
The define of snprintf to sprintf_s is applied before stdio headers
are included, causing it to be applied to the headers themselves,
breaking mingw-w64 headers targeting UCRT (because the headers provide
declarations for both snprintf and sprintf_s, but one of them is
declared as a static inline while the other is not).
In upstream libnfs, this define was entirely commented out in
6564abaa1f979c0b62044f695030a32b60620163.
---
contrib/src/nfs/mingw-snprintf.patch | 12 ++++++++++++
contrib/src/nfs/rules.mak | 1 +
2 files changed, 13 insertions(+)
create mode 100644 contrib/src/nfs/mingw-snprintf.patch
diff --git a/contrib/src/nfs/mingw-snprintf.patch b/contrib/src/nfs/mingw-snprintf.patch
new file mode 100644
index 0000000000..a2fa01a3a6
--- /dev/null
+++ b/contrib/src/nfs/mingw-snprintf.patch
@@ -0,0 +1,12 @@
+--- nfs/include/win32/win32_compat.h.orig 2021-03-13 12:53:05.958765143 +0200
++++ nfs/include/win32/win32_compat.h 2021-03-13 10:49:11.848691119 +0200
+@@ -133,7 +133,9 @@
+
+ /* Wrapper macros to call misc. functions win32 is missing */
+ #define poll(x, y, z) win32_poll(x, y, z)
++#ifndef __MINGW32__
+ #define snprintf sprintf_s
++#endif
+ #define inet_pton(x,y,z) win32_inet_pton(x,y,z)
+ #define open(x, y, z) _open(x, y, z)
+ #ifndef lseek
diff --git a/contrib/src/nfs/rules.mak b/contrib/src/nfs/rules.mak
index b65816c37d..c880c5d142 100644
--- a/contrib/src/nfs/rules.mak
+++ b/contrib/src/nfs/rules.mak
@@ -15,6 +15,7 @@ $(TARBALLS)/libnfs-$(NFS_VERSION).tar.gz:
nfs: libnfs-$(NFS_VERSION).tar.gz .sum-nfs
$(UNPACK)
mv libnfs-libnfs-$(NFS_VERSION) libnfs-$(NFS_VERSION)
+ $(APPLY) $(SRC)/nfs/mingw-snprintf.patch
$(UPDATE_AUTOCONFIG)
$(MOVE)
--
2.25.1
More information about the vlc-devel
mailing list