Subject: Re: bug#74312: 31.0.50; Cygw32 build break

From: Kazuhiro Ito <[email-masked]>
Date: Wed, 13 Nov 2024 01:14:54 +0900

> > ../../src/w32menu.c: In function ‘w32_popup_dialog’:
> > ../../src/w32menu.c:200:21: warning: implicit declaration of function 
> > ‘pMultiByteToWideChar’; did you mean ‘MultiByteToWideChar’? 
> > [-Wimplicit-function-declaration]
> >    200 |                   * pMultiByteToWideChar (CP_UTF8, 0, title, 
> > -1, NULL, 0));
> >        |                     ^~~~~~~~~~~~~~~~~~~~
> >        |                     MultiByteToWideChar
> > ../../src/w32menu.c:200:21: warning: nested extern declaration of 
> > ‘pMultiByteToWideChar’ [-Wnested-externs]
> > 
> > ../../src/w32dwrite.c:41: warning: macro "INITGUID" is not used 
> > [-Wunused-macros]
> >     41 | # define INITGUID
> >        |
> > ../../src/w32dwrite.c: In function ‘w32_dwrite_encode_char’:
> > ../../src/w32dwrite.c:662:51: warning: pointer targets in passing 
> > argument 2 of ‘dwrite_font_face->lpVtbl->GetGlyphIndicesA’ differ in 
> > signedness [-Wpointer-sign]
> >    662 |                                                   &c, 1, &index);
> >        |                                                   ^~
> >        |                                                   |
> >        |                                                   int *
> > ../../src/w32dwrite.c:662:51: note: expected ‘const UINT32 *’ {aka 
> > ‘const unsigned int *’} but argument is of type ‘int *’
> > 
> > /usr/lib/gcc/x86_64-pc-cygwin/12/../../../../x86_64-pc-cygwin/bin/ld: 
> > w32menu.o: in function `w32_popup_dialog':
> > /home/kbrown/src/emacs/master/build-w32/src/../../src/w32menu.c:200:(.text+0xb6a): 
> > undefined reference to `pMultiByteToWideChar'
> > /usr/lib/gcc/x86_64-pc-cygwin/12/../../../../x86_64-pc-cygwin/bin/ld: 
> > /home/kbrown/src/emacs/master/build-w32/src/../../src/w32menu.c:202:(.text+0xba5): 
> > undefined reference to `pMultiByteToWideChar'
> > /usr/lib/gcc/x86_64-pc-cygwin/12/../../../../x86_64-pc-cygwin/bin/ld: 
> > /home/kbrown/src/emacs/master/build-w32/src/../../src/w32menu.c:252:(.text+0xc1e): 
> > undefined reference to `pMultiByteToWideChar'
> > /usr/lib/gcc/x86_64-pc-cygwin/12/../../../../x86_64-pc-cygwin/bin/ld: 
> > /home/kbrown/src/emacs/master/build-w32/src/../../src/w32menu.c:256:(.text+0xc6a): 
> > undefined reference to `pMultiByteToWideChar'
> > /usr/lib/gcc/x86_64-pc-cygwin/12/../../../../x86_64-pc-cygwin/bin/ld: 
> > /home/kbrown/src/emacs/master/build-w32/src/../../src/w32menu.c:230:(.text+0xdfe): 
> > undefined reference to `pMultiByteToWideChar'
> > /usr/lib/gcc/x86_64-pc-cygwin/12/../../../../x86_64-pc-cygwin/bin/ld: 
> > w32menu.o:/home/kbrown/src/emacs/master/build-w32/src/../../src/w32menu.c:233: 
> > more undefined references to `pMultiByteToWideChar' follow
>
> Thanks, I tried to fix those.

As far as I tested, modifying your change as below was needed.  

diff --git a/src/w32menu.c b/src/w32menu.c
index b5f87ebb42c..e5415b89bcb 100644
--- a/src/w32menu.c
+++ b/src/w32menu.c
@@ -187,8 +187,8 @@ task_dialog_callback (HWND hwnd, UINT msg, WPARAM wParam,
 w32_popup_dialog (struct frame *f, Lisp_Object header, Lisp_Object contents)
 {
 #ifdef NTGUI_UNICODE
-  typedef int (WINAPI *WideCharToMultiByte_Proc)(UINT,DWORD,LPCWSTR,int,LPSTR,
-						 int,LPCSTR,LPBOOL);
+  typedef int (WINAPI *MultiByteToWideChar_Proc)(UINT,DWORD,LPCSTR,int,
+						 LPWSTR,int);
   static MultiByteToWideChar_Proc pMultiByteToWideChar = MultiByteToWideChar;
 #endif /* NTGUI_UNICODE */
   check_window_system (f);

> And when it does build, please try the drag-n-drop feature, both with
> dropping files and with dropping text on Emacs.

Dropping multiple files or text works the same as MingW build except
files and directories with non-ascii name.  When I dragged such files
in Emacs frame, mouse cursor changed into red NO ENTRY SIGN (U+1F6AB)
and no response for dropping.

-- 
Kazuhiro Ito