[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
lstat: Fix compilation error in C++ mode on mingw
From: |
Bruno Haible |
Subject: |
lstat: Fix compilation error in C++ mode on mingw |
Date: |
Sun, 04 Sep 2022 16:09:07 +0200 |
In a testdir build on mingw, I get this compilation error:
depbase=`echo test-sys_stat-c++.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
x86_64-w64-mingw32-g++ -DHAVE_CONFIG_H -DEXEEXT=\".exe\" -I. -I../../gltests
-I.. -DGNULIB_STRICT_CHECKING=1 -DIN_GNULIB_TESTS=1 -I. -I../../gltests -I..
-I../../gltests/.. -I../gllib -I../../gltests/../gllib
-D_WIN32_WINNT=_WIN32_WINNT_WINXP -I/usr/local/mingw64/include -Wall
-Wno-error -g -O2 -MT test-sys_stat-c++.o -MD -MP -MF $depbase.Tpo -c -o
test-sys_stat-c++.o ../../gltests/test-sys_stat-c++.cc &&\
mv -f $depbase.Tpo $depbase.Po
In file included from /usr/x86_64-w64-mingw32/sys-root/mingw/include/io.h:10:0,
from
/usr/x86_64-w64-mingw32/sys-root/mingw/include/unistd.h:10,
from ../gllib/unistd.h:40,
from ../gllib/time.h:44,
from ../gllib/sys/stat.h:44,
from ../../gltests/test-sys_stat-c++.cc:22:
../gllib/sys/stat.h: In member function 'gnulib::_gl_lstat_wrapper::operator
gnulib::_gl_lstat_wrapper::type() const':
../gllib/sys/stat.h:1113:1: error: expected primary-expression before ';' token
_GL_CXXALIAS_RPL_1 (lstat, stat, int,
^
make[4]: *** [Makefile:23382: test-sys_stat-c++.o] Error 1
The reason is that 'lstat' expands to 'stat', which expands to 'rpl_stat', but
the function rpl_stat() is not yet declared at this point.
This patch fixes it.
2022-09-04 Bruno Haible <bruno@clisp.org>
lstat: Fix compilation error in C++ mode on mingw.
* lib/sys_stat.h (lstat): Move declaration after the declaration of
'stat'.
diff --git a/lib/sys_stat.in.h b/lib/sys_stat.in.h
index 714c3cb189..0ec320f58c 100644
--- a/lib/sys_stat.in.h
+++ b/lib/sys_stat.in.h
@@ -596,44 +596,6 @@ _GL_WARN_ON_USE (lchmod, "lchmod is unportable - "
#endif
-#if @GNULIB_LSTAT@
-# if ! @HAVE_LSTAT@
-/* mingw does not support symlinks, therefore it does not have lstat. But
- without links, stat does just fine. */
-# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-# define lstat stat
-# endif
-_GL_CXXALIAS_RPL_1 (lstat, stat, int,
- (const char *restrict name, struct stat *restrict buf));
-# elif @REPLACE_LSTAT@
-# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-# undef lstat
-# define lstat rpl_lstat
-# endif
-_GL_FUNCDECL_RPL (lstat, int,
- (const char *restrict name, struct stat *restrict buf)
- _GL_ARG_NONNULL ((1, 2)));
-_GL_CXXALIAS_RPL (lstat, int,
- (const char *restrict name, struct stat *restrict buf));
-# else
-_GL_CXXALIAS_SYS (lstat, int,
- (const char *restrict name, struct stat *restrict buf));
-# endif
-# if @HAVE_LSTAT@
-_GL_CXXALIASWARN (lstat);
-# endif
-#elif @GNULIB_OVERRIDES_STRUCT_STAT@
-# undef lstat
-# define lstat lstat_used_without_requesting_gnulib_module_lstat
-#elif defined GNULIB_POSIXCHECK
-# undef lstat
-# if HAVE_RAW_DECL_LSTAT
-_GL_WARN_ON_USE (lstat, "lstat is unportable - "
- "use gnulib module lstat for portability");
-# endif
-#endif
-
-
#if @GNULIB_MKDIR@
# if @REPLACE_MKDIR@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -895,6 +857,44 @@ _GL_WARN_ON_USE (stat, "stat is unportable - "
#endif
+#if @GNULIB_LSTAT@
+# if ! @HAVE_LSTAT@
+/* mingw does not support symlinks, therefore it does not have lstat. But
+ without links, stat does just fine. */
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define lstat stat
+# endif
+_GL_CXXALIAS_RPL_1 (lstat, stat, int,
+ (const char *restrict name, struct stat *restrict buf));
+# elif @REPLACE_LSTAT@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef lstat
+# define lstat rpl_lstat
+# endif
+_GL_FUNCDECL_RPL (lstat, int,
+ (const char *restrict name, struct stat *restrict buf)
+ _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (lstat, int,
+ (const char *restrict name, struct stat *restrict buf));
+# else
+_GL_CXXALIAS_SYS (lstat, int,
+ (const char *restrict name, struct stat *restrict buf));
+# endif
+# if @HAVE_LSTAT@
+_GL_CXXALIASWARN (lstat);
+# endif
+#elif @GNULIB_OVERRIDES_STRUCT_STAT@
+# undef lstat
+# define lstat lstat_used_without_requesting_gnulib_module_lstat
+#elif defined GNULIB_POSIXCHECK
+# undef lstat
+# if HAVE_RAW_DECL_LSTAT
+_GL_WARN_ON_USE (lstat, "lstat is unportable - "
+ "use gnulib module lstat for portability");
+# endif
+#endif
+
+
#if @GNULIB_MDA_UMASK@
/* On native Windows, map 'umask' to '_umask', so that -loldnames is not
required. In C++ with GNULIB_NAMESPACE, avoid differences between
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- lstat: Fix compilation error in C++ mode on mingw,
Bruno Haible <=