summaryrefslogtreecommitdiff
path: root/lib/ftruncate.c
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2020-05-28 02:06:51 +0200
committerBruno Haible <bruno@clisp.org>2020-05-28 02:06:51 +0200
commite0dc0ffc6f2f2a4826156d7451e1dc6e80e53243 (patch)
tree6196a3f129d889d3104b15dc595f5f01f04eea37 /lib/ftruncate.c
parent41b5ed4b01857881d356e15f86b3dd081fe3f6c8 (diff)
downloadgnulib-e0dc0ffc6f2f2a4826156d7451e1dc6e80e53243.tar.gz
Improve pattern for defining _WIN32_WINNT.
Newer versions of the Windows API may not only add, but also remove API functions. Therefore, when the user is e.g. building for Windows 10, we should not set _WIN32_WINNT to e.g. Windows 8, as this may enable the use of APIs that were present in Windows 8 but removed in Windows 10. Suggested by Steve Lhomme <robux4@ycbcr.xyz> in <https://lists.gnu.org/archive/html/bug-gnulib/2020-05/msg00318.html>. * lib/ftruncate.c (_WIN32_WINNT): Don't set to a smaller value. * lib/sethostname.c (_WIN32_WINNT): Likewise. * lib/stat-w32.c (_WIN32_WINNT): Likewise.
Diffstat (limited to 'lib/ftruncate.c')
-rw-r--r--lib/ftruncate.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/ftruncate.c b/lib/ftruncate.c
index a1856374e8..2514075e51 100644
--- a/lib/ftruncate.c
+++ b/lib/ftruncate.c
@@ -30,8 +30,10 @@
argument. So, define a 64-bit safe SetFileSize function ourselves. */
/* Ensure that <windows.h> declares GetFileSizeEx. */
-# undef _WIN32_WINNT
-# define _WIN32_WINNT _WIN32_WINNT_WIN2K
+# if !defined _WIN32_WINNT || (_WIN32_WINNT < _WIN32_WINNT_WIN2K)
+# undef _WIN32_WINNT
+# define _WIN32_WINNT _WIN32_WINNT_WIN2K
+# endif
/* Get declarations of the native Windows API functions. */
# define WIN32_LEAN_AND_MEAN