bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

pathmax: support for native Windows


From: Bruno Haible
Subject: pathmax: support for native Windows
Date: Tue, 13 Sep 2011 13:04:31 +0200
User-agent: KMail/1.13.6 (Linux/2.6.37.6-0.5-desktop; KDE/4.6.0; x86_64; ; )

lib/tmpfile.c and lib/tmpdir.c give compilation errors on MSVC 9,
because PATH_MAX is not defined.

Also, mingw defines PATH_MAX in <limits.h>, but to a wrong value (259
instead of 260). Same mistake as on HP-UX.

This fixes it:


2011-09-13  Bruno Haible  <address@hidden>

        pathmax: Support for native Windows.
        * lib/pathmax.h (PATH_MAX): Define to 260 on native Windows.

--- lib/pathmax.h.orig  Tue Sep 13 12:59:55 2011
+++ lib/pathmax.h       Tue Sep 13 12:32:15 2011
@@ -66,4 +66,19 @@
 #  define PATH_MAX 1024
 # endif
 
+# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+/* The page "Naming Files, Paths, and Namespaces" on msdn.microsoft.com,
+   section "Maximum Path Length Limitation",
+   <http://msdn.microsoft.com/en-us/library/aa365247(v=vs.85).aspx#maxpath>
+   explains that the maximum size of a filename, including the terminating
+   NUL byte, is 260 = 3 + 256 + 1.
+   This is the same value as
+     - FILENAME_MAX in <stdio.h>,
+     - _MAX_PATH in <stdlib.h>,
+     - MAX_PATH in <windef.h>.
+   Undefine the original value, because mingw's <limits.h> gets it wrong.  */
+#  undef PATH_MAX
+#  define PATH_MAX 260
+# endif
+
 #endif /* _PATHMAX_H */
-- 
In memoriam Ketevan of Mukhrani 
<http://en.wikipedia.org/wiki/Ketevan_of_Mukhrani>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]