Subject: Re: bug#14043: 24.3.50; Compiler warning in cygw32 build on x86_64-cygwin

From: Eli Zaretskii <[email-masked]>
Date: Sat, 23 Mar 2013 20:25:03 +0200

> Date: Sat, 23 Mar 2013 12:40:38 -0400
> From: Ken Brown <[email-masked]>
> 
> In w32term.c:w32_initialize, the line
> 
>    DWORD input_locale_id = (DWORD) GetKeyboardLayout (0);
> 
> (line 6666 in the current trunk) generates a "cast from pointer to 
> integer of different size" warning in the cygw32 build on 64-bit Cygwin. 
>   I think that the warning can be safely ignored in this case, but I 
> would prefer to avoid it.
> 
> The attached patch fixes this.

Does the alternative patch below also work?  I'd like to avoid
ifdef's, if possible.  If you still see a warning, please show the
64-bit Cygwin definitions for DWORD, DWORD_PTR, HANDLE, and HKL.

> I'm wondering, however, whether the same warning occurs on 64-bit
> Windows.

The Microsoft compiler emits much more warnings than even the latest
picky versions of GCC, so I'm quite sure it also warns here, and the
warning is (quite correctly) ignored.

=== modified file 'src/w32term.c'
--- src/w32term.c	2013-03-23 09:01:14 +0000
+++ src/w32term.c	2013-03-23 18:19:24 +0000
@@ -6663,7 +6663,7 @@ w32_initialize (void)
   Fset_input_mode (Qnil, Qnil, make_number (2), Qnil);
 
   {
-    DWORD input_locale_id = (DWORD) GetKeyboardLayout (0);
+    DWORD input_locale_id = ((DWORD_PTR) GetKeyboardLayout (0) & 0xffffffff);
     w32_keyboard_codepage =
       codepage_for_locale ((LCID) (input_locale_id & 0xffff));
   }