diff mbox

[v2] gtk: avoid redefining _WIN32_WINNT macro

Message ID 1441708475-27578-1-git-send-email-berrange@redhat.com
State New
Headers show

Commit Message

Daniel P. Berrangé Sept. 8, 2015, 10:34 a.m. UTC
When building for Mingw64 target on Fedora 22 a warning
is issued about _WIN32_WINNT being redefined.

In file included from ui/gtk.c:40:0:
include/ui/gtk.h:5:0: warning: "_WIN32_WINNT" redefined
 # define _WIN32_WINNT 0x0601 /* needed to get definition of MAPVK_VK_TO_VSC */
  ^
In file included from /usr/i686-w64-mingw32/sys-root/mingw/include/crtdefs.h:10:0,
                 from /usr/i686-w64-mingw32/sys-root/mingw/include/stdio.h:9,
                 from /home/berrange/src/virt/qemu/include/qemu/fprintf-fn.h:12,
                 from /home/berrange/src/virt/qemu/include/qemu-common.h:18,
                 from ui/gtk.c:37:
/usr/i686-w64-mingw32/sys-root/mingw/include/_mingw.h:225:0: note: this is the location of the previous definition
 #define _WIN32_WINNT 0x502
 ^

Rather than try to get MAPVK_VK_TO_VSC defined indirectly
by defining _WIN32_WINNT, instead just define it explicitly
if missing.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
---
 include/ui/gtk.h | 4 ----
 ui/gtk.c         | 9 +++++++++
 2 files changed, 9 insertions(+), 4 deletions(-)

Comments

Paolo Bonzini Sept. 8, 2015, 1:53 p.m. UTC | #1
----- Messaggio originale -----
> Da: "Daniel P. Berrange" <berrange@redhat.com>
> A: qemu-devel@nongnu.org
> Cc: "Gerd Hoffmann" <kraxel@redhat.com>, qemu-trivial@nongnu.org, "Paolo Bonzini" <pbonzini@redhat.com>, "Stefan
> Weil" <sw@weilnetz.de>, "Daniel P. Berrange" <berrange@redhat.com>
> Inviato: Martedì, 8 settembre 2015 12:34:35
> Oggetto: [PATCH v2] gtk: avoid redefining _WIN32_WINNT macro
> 
> When building for Mingw64 target on Fedora 22 a warning
> is issued about _WIN32_WINNT being redefined.
> 
> In file included from ui/gtk.c:40:0:
> include/ui/gtk.h:5:0: warning: "_WIN32_WINNT" redefined
>  # define _WIN32_WINNT 0x0601 /* needed to get definition of MAPVK_VK_TO_VSC
>  */
>   ^
> In file included from
> /usr/i686-w64-mingw32/sys-root/mingw/include/crtdefs.h:10:0,
>                  from /usr/i686-w64-mingw32/sys-root/mingw/include/stdio.h:9,
>                  from
>                  /home/berrange/src/virt/qemu/include/qemu/fprintf-fn.h:12,
>                  from /home/berrange/src/virt/qemu/include/qemu-common.h:18,
>                  from ui/gtk.c:37:
> /usr/i686-w64-mingw32/sys-root/mingw/include/_mingw.h:225:0: note: this is
> the location of the previous definition
>  #define _WIN32_WINNT 0x502
>  ^
> 
> Rather than try to get MAPVK_VK_TO_VSC defined indirectly
> by defining _WIN32_WINNT, instead just define it explicitly
> if missing.
> 
> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
> ---
>  include/ui/gtk.h | 4 ----
>  ui/gtk.c         | 9 +++++++++
>  2 files changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/include/ui/gtk.h b/include/ui/gtk.h
> index ee6dffd..0359333 100644
> --- a/include/ui/gtk.h
> +++ b/include/ui/gtk.h
> @@ -1,10 +1,6 @@
>  #ifndef UI_GTK_H
>  #define UI_GTK_H
>  
> -#ifdef _WIN32
> -# define _WIN32_WINNT 0x0601 /* needed to get definition of MAPVK_VK_TO_VSC
> */
> -#endif
> -
>  #ifdef CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE
>  /* Work around an -Wstrict-prototypes warning in GTK headers */
>  #pragma GCC diagnostic push
> diff --git a/ui/gtk.c b/ui/gtk.c
> index df2a79e..80d5c20 100644
> --- a/ui/gtk.c
> +++ b/ui/gtk.c
> @@ -104,6 +104,15 @@
>  #define GDK_KEY_Pause GDK_Pause
>  #endif
>  
> +/* Some older mingw versions lack this constant or have
> + * it conditionally defined */
> +#ifdef _WIN32
> +# ifndef MAPVK_VK_TO_VSC
> +#  define MAPVK_VK_TO_VSC 0
> +# endif
> +#endif
> +
> +
>  #define HOTKEY_MODIFIERS        (GDK_CONTROL_MASK | GDK_MOD1_MASK)
>  
>  static const int modifier_keycode[] = {
> --
> 2.4.3
> 
> 

Nice, thanks!

Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Stefan Weil Sept. 8, 2015, 6:39 p.m. UTC | #2
Am 08.09.2015 um 15:53 schrieb Paolo Bonzini:
> 
> 
> ----- Messaggio originale -----
>> Da: "Daniel P. Berrange" <berrange@redhat.com>
>> A: qemu-devel@nongnu.org
>> Cc: "Gerd Hoffmann" <kraxel@redhat.com>, qemu-trivial@nongnu.org, "Paolo Bonzini" <pbonzini@redhat.com>, "Stefan
>> Weil" <sw@weilnetz.de>, "Daniel P. Berrange" <berrange@redhat.com>
>> Inviato: Martedì, 8 settembre 2015 12:34:35
>> Oggetto: [PATCH v2] gtk: avoid redefining _WIN32_WINNT macro
>>
>> When building for Mingw64 target on Fedora 22 a warning
>> is issued about _WIN32_WINNT being redefined.
>>
>> In file included from ui/gtk.c:40:0:
>> include/ui/gtk.h:5:0: warning: "_WIN32_WINNT" redefined
>>  # define _WIN32_WINNT 0x0601 /* needed to get definition of MAPVK_VK_TO_VSC
>>  */
>>   ^
>> In file included from
>> /usr/i686-w64-mingw32/sys-root/mingw/include/crtdefs.h:10:0,
>>                  from /usr/i686-w64-mingw32/sys-root/mingw/include/stdio.h:9,
>>                  from
>>                  /home/berrange/src/virt/qemu/include/qemu/fprintf-fn.h:12,
>>                  from /home/berrange/src/virt/qemu/include/qemu-common.h:18,
>>                  from ui/gtk.c:37:
>> /usr/i686-w64-mingw32/sys-root/mingw/include/_mingw.h:225:0: note: this is
>> the location of the previous definition
>>  #define _WIN32_WINNT 0x502
>>  ^
>>
>> Rather than try to get MAPVK_VK_TO_VSC defined indirectly
>> by defining _WIN32_WINNT, instead just define it explicitly
>> if missing.
>>
>> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
>> ---
>>  include/ui/gtk.h | 4 ----
>>  ui/gtk.c         | 9 +++++++++
>>  2 files changed, 9 insertions(+), 4 deletions(-)
>>
>> diff --git a/include/ui/gtk.h b/include/ui/gtk.h
>> index ee6dffd..0359333 100644
>> --- a/include/ui/gtk.h
>> +++ b/include/ui/gtk.h
>> @@ -1,10 +1,6 @@
>>  #ifndef UI_GTK_H
>>  #define UI_GTK_H
>>  
>> -#ifdef _WIN32
>> -# define _WIN32_WINNT 0x0601 /* needed to get definition of MAPVK_VK_TO_VSC
>> */
>> -#endif
>> -
>>  #ifdef CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE
>>  /* Work around an -Wstrict-prototypes warning in GTK headers */
>>  #pragma GCC diagnostic push
>> diff --git a/ui/gtk.c b/ui/gtk.c
>> index df2a79e..80d5c20 100644
>> --- a/ui/gtk.c
>> +++ b/ui/gtk.c
>> @@ -104,6 +104,15 @@
>>  #define GDK_KEY_Pause GDK_Pause
>>  #endif
>>  
>> +/* Some older mingw versions lack this constant or have
>> + * it conditionally defined */
>> +#ifdef _WIN32
>> +# ifndef MAPVK_VK_TO_VSC
>> +#  define MAPVK_VK_TO_VSC 0
>> +# endif
>> +#endif
>> +
>> +
>>  #define HOTKEY_MODIFIERS        (GDK_CONTROL_MASK | GDK_MOD1_MASK)
>>  
>>  static const int modifier_keycode[] = {
>> --
>> 2.4.3
>>
>>
> 
> Nice, thanks!
> 
> Acked-by: Paolo Bonzini <pbonzini@redhat.com>
> 

Thanks, applied to my Windows patch queue
(git://qemu.weilnetz.de/qemu.git wxx)

Stefan
diff mbox

Patch

diff --git a/include/ui/gtk.h b/include/ui/gtk.h
index ee6dffd..0359333 100644
--- a/include/ui/gtk.h
+++ b/include/ui/gtk.h
@@ -1,10 +1,6 @@ 
 #ifndef UI_GTK_H
 #define UI_GTK_H
 
-#ifdef _WIN32
-# define _WIN32_WINNT 0x0601 /* needed to get definition of MAPVK_VK_TO_VSC */
-#endif
-
 #ifdef CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE
 /* Work around an -Wstrict-prototypes warning in GTK headers */
 #pragma GCC diagnostic push
diff --git a/ui/gtk.c b/ui/gtk.c
index df2a79e..80d5c20 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -104,6 +104,15 @@ 
 #define GDK_KEY_Pause GDK_Pause
 #endif
 
+/* Some older mingw versions lack this constant or have
+ * it conditionally defined */
+#ifdef _WIN32
+# ifndef MAPVK_VK_TO_VSC
+#  define MAPVK_VK_TO_VSC 0
+# endif
+#endif
+
+
 #define HOTKEY_MODIFIERS        (GDK_CONTROL_MASK | GDK_MOD1_MASK)
 
 static const int modifier_keycode[] = {