Building a testdir for module 'utime-h' with C++ tests on MSVC, I see this
error:

../gllib\utime.h(646): error C2440: 'return': cannot convert from 'int (__cdecl 
*)(const char *const ,_utimbuf *const )' to 'gnulib::_gl_utime_wrapper::type'
../gllib\utime.h(646): note: This conversion requires a reinterpret_cast, a 
C-style cast or function-style cast
make[5]: *** [Makefile:784: test-utime-h-c++.obj] Error 2

This patch fixes it.


2025-05-25  Bruno Haible  <br...@clisp.org>

        utime-h: Fix error in C++ mode with MSVC.
        * lib/utime.in.h (utime): Use _GL_CXXALIAS_MDA_CAST instead of
        _GL_CXXALIAS_MDA.

diff --git a/lib/utime.in.h b/lib/utime.in.h
index 0ac9993f9d..10ba32ccec 100644
--- a/lib/utime.in.h
+++ b/lib/utime.in.h
@@ -106,7 +106,9 @@ _GL_WARN_ON_USE (utime,
 #   undef utime
 #   define utime _utime
 #  endif
-_GL_CXXALIAS_MDA (utime, int, (const char *filename, const struct utimbuf 
*ts));
+/* Need to cast, because on MSVC, the second parameter is of type
+   'struct _utimbuf *'.  */
+_GL_CXXALIAS_MDA_CAST (utime, int, (const char *filename, const struct utimbuf 
*ts));
 # else
 _GL_CXXALIAS_SYS (utime, int, (const char *filename, const struct utimbuf 
*ts));
 # endif




Reply via email to