On MSVC 9, I'm getting a syntax error in gnulib's <sys/stat.h> here: static inline int rpl_mkdir (char const *name, mode_t mode)
because mode_t is not defined. According to POSIX:2008, mode_t ought to be defined in each of <fcntl.h> <spawn.h> <sys/stat.h> <sys/types.h> (and other headers which gnulib does not support yet). Here's the fix. 2011-09-16 Bruno Haible <br...@clisp.org> Support for MSVC compiler: Ensure mode_t gets defined. * m4/fcntl_h.m4 (gl_FCNTL_H): Require AC_TYPE_MODE_T. * m4/spawn_h.m4 (gl_SPAWN_H): Likewise. * m4/sys_stat_h.m4 (gl_HEADER_SYS_STAT_H): Likewise. * m4/sys_types_h.m4 (gl_SYS_TYPES_H): Likewise. * tests/test-fcntl-h.c: Check that mode_t is defined. * tests/test-sys_stat.c: Likewise. * tests/test-sys_types.c: Likewise. * doc/posix-headers/fcntl.texi: Mention the missing mode_t problem. * doc/posix-headers/sys_stat.texi: Likewise. * doc/posix-headers/sys_types.texi: Likewise. --- doc/posix-headers/fcntl.texi.orig Fri Sep 16 23:38:10 2011 +++ doc/posix-headers/fcntl.texi Fri Sep 16 23:33:52 2011 @@ -12,6 +12,10 @@ MSVC 9. @item +The type @code{mode_t} is not defined on some platforms: +MSVC 9. + +@item @samp{O_CLOEXEC}, @samp{O_DIRECTORY}, @samp{O_DSYNC}, @samp{O_NOCTTY}, @samp{O_NOFOLLOW}, @samp{O_RSYNC}, @samp{O_SYNC}, and @samp{O_TTY_INIT} are not defined on some platforms. Gnulib defines --- doc/posix-headers/sys_stat.texi.orig Fri Sep 16 23:38:10 2011 +++ doc/posix-headers/sys_stat.texi Fri Sep 16 23:33:52 2011 @@ -8,6 +8,9 @@ Portability problems fixed by Gnulib: @itemize @item +The type @code{mode_t} is not defined on some platforms: +MSVC 9. +@item Some macros, such as @code{S_IFMT} or @code{S_IFIFO}, are missing on some platforms. @item --- doc/posix-headers/sys_types.texi.orig Fri Sep 16 23:38:10 2011 +++ doc/posix-headers/sys_types.texi Fri Sep 16 23:33:53 2011 @@ -16,6 +16,9 @@ @item The type @code{ssize_t} is not defined on some platforms: MSVC 9. +@item +The type @code{mode_t} is not defined on some platforms: +MSVC 9. @end itemize Portability problems not fixed by Gnulib: --- m4/fcntl_h.m4.orig Fri Sep 16 23:38:11 2011 +++ m4/fcntl_h.m4 Fri Sep 16 23:35:13 2011 @@ -1,4 +1,4 @@ -# serial 14 +# serial 15 # Configure fcntl.h. dnl Copyright (C) 2006-2007, 2009-2011 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation @@ -16,6 +16,9 @@ dnl Ensure the type pid_t gets defined. AC_REQUIRE([AC_TYPE_PID_T]) + dnl Ensure the type mode_t gets defined. + AC_REQUIRE([AC_TYPE_MODE_T]) + dnl Check for declarations of anything we want to poison if the dnl corresponding gnulib module is not in use, if it is not common dnl enough to be declared everywhere. --- m4/spawn_h.m4.orig Fri Sep 16 23:38:11 2011 +++ m4/spawn_h.m4 Fri Sep 16 23:35:14 2011 @@ -1,4 +1,4 @@ -# spawn_h.m4 serial 14 +# spawn_h.m4 serial 15 dnl Copyright (C) 2008-2011 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -34,6 +34,9 @@ dnl Ensure the type pid_t gets defined. AC_REQUIRE([AC_TYPE_PID_T]) + dnl Ensure the type mode_t gets defined. + AC_REQUIRE([AC_TYPE_MODE_T]) + AC_REQUIRE([gl_HAVE_POSIX_SPAWN]) AC_REQUIRE([AC_C_RESTRICT]) --- m4/sys_stat_h.m4.orig Fri Sep 16 23:38:11 2011 +++ m4/sys_stat_h.m4 Fri Sep 16 23:35:14 2011 @@ -1,4 +1,4 @@ -# sys_stat_h.m4 serial 24 -*- Autoconf -*- +# sys_stat_h.m4 serial 25 -*- Autoconf -*- dnl Copyright (C) 2006-2011 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -19,6 +19,9 @@ gl_CHECK_NEXT_HEADERS([sys/stat.h]) + dnl Ensure the type mode_t gets defined. + AC_REQUIRE([AC_TYPE_MODE_T]) + dnl Define types that are supposed to be defined in <sys/types.h> or dnl <sys/stat.h>. AC_CHECK_TYPE([nlink_t], [], --- m4/sys_types_h.m4.orig Fri Sep 16 23:38:11 2011 +++ m4/sys_types_h.m4 Fri Sep 16 23:35:14 2011 @@ -1,4 +1,4 @@ -# sys_types_h.m4 serial 1 +# sys_types_h.m4 serial 2 dnl Copyright (C) 2011 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -11,6 +11,9 @@ dnl Ensure the type pid_t gets defined. AC_REQUIRE([AC_TYPE_PID_T]) + + dnl Ensure the type mode_t gets defined. + AC_REQUIRE([AC_TYPE_MODE_T]) ]) AC_DEFUN([gl_SYS_TYPES_H_DEFAULTS], --- tests/test-fcntl-h.c.orig Fri Sep 16 23:38:11 2011 +++ tests/test-fcntl-h.c Fri Sep 16 23:33:42 2011 @@ -34,6 +34,7 @@ /* Check that the types are all defined. */ pid_t t1; off_t t2; +mode_t t3; int main (void) --- tests/test-sys_stat.c.orig Fri Sep 16 23:38:11 2011 +++ tests/test-sys_stat.c Fri Sep 16 23:33:42 2011 @@ -314,8 +314,9 @@ /* Check the existence of some types. */ nlink_t t1; off_t t2; +mode_t t3; -struct timespec t3; +struct timespec st; int main (void) --- tests/test-sys_types.c.orig Fri Sep 16 23:38:11 2011 +++ tests/test-sys_types.c Fri Sep 16 23:33:42 2011 @@ -25,6 +25,7 @@ size_t t2; ssize_t t3; off_t t4; +mode_t t5; int main (void) -- In memoriam Georgiy Gongadze <http://en.wikipedia.org/wiki/Georgiy_Gongadze>