gtk: avoid redefining _WIN32_WINNT macro
PATCH 1/1 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
^--- include/ui/gtk.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
include/ui/gtk.h +3 -1
@@ -2,7 +2,9 @@#define UI_GTK_H #ifdef _WIN32 -# define _WIN32_WINNT 0x0601/* needed to get definition of MAPVK_VK_TO_VSC */ +# ifndef _WIN32_WINNT +# define _WIN32_WINNT 0x0601/* needed to get definition of MAPVK_VK_TO_VSC */ +# endif #endif #ifdef CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE
Signature · 1 line
2.4.3
Quoted 23 lines · Daniel P. Berrange
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 ^Signed-off-by Daniel P. Berrange <[email protected]>--- include/ui/gtk.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)include/ui/gtk.h +0
-0
include/ui/gtk.h line 8
Quoted 8 lines
include/ui/gtk.h +3
-1@@ -2,7 +2,9 @@#define UI_GTK_H #ifdef _WIN32 -# define _WIN32_WINNT 0x0601/* needed to get definition of MAPVK_VK_TO_VSC */ +# ifndef _WIN32_WINNT +# define _WIN32_WINNT 0x0601/* needed to get definition of MAPVK_VK_TO_VSC */ +# endif #endif
Your error message shows that _WIN32_WINNT was 0x0502, do you get MAPVK_VK_TO_VSC with this patch?
Perhaps #undef the macro first, or do something like:
#if !defined _WIN32_WINNT || _WIN32_WINNT < 0x0601
# undef _WIN32_WINNT # define _WIN32_WINNT 0x0601 #endif
Paolo
Quoted 28 lines · Paolo Bonzini
Quoted 25 lines · Daniel P. Berrange
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 ^Signed-off-by Daniel P. Berrange <[email protected]>--- include/ui/gtk.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)include/ui/gtk.h +0
-0@@ -2,7 +2,9 @@#define UI_GTK_H
Quoted 9 lines
include/ui/gtk.h line 8
Quoted 6 lines
include/ui/gtk.h +3
-1#ifdef _WIN32 -# define _WIN32_WINNT 0x0601/* needed to get definition of MAPVK_VK_TO_VSC */ +# ifndef _WIN32_WINNT +# define _WIN32_WINNT 0x0601/* needed to get definition of MAPVK_VK_TO_VSC */ +# endif #endif Your error message shows that
_WIN32_WINNTwas0x0502, do you getMAPVK_VK_TO_VSCwith this patch?
Yes, it still sees that constant just fine and compiles without error.
Interestingly, looking at the header files in mingw64 for Fedora 18 and Fedora 22, I see
#define MAPVK_VK_TO_VSC 0 #define MAPVK_VSC_TO_VK 1 #define MAPVK_VK_TO_CHAR 2
#define MAPVK_VSC_TO_VK_EX 3
#if (_WIN32_WINNT >= 0x0600)
#define MAPVK_VK_TO_VSC_EX 4
#endif
IOW, the constant we use is made available unconditionally, only the _EX variant needs the _WIN32_WINNT definition.
I wonder if there are some very old mingw versions which lack it though ?
Quoted 6 lines
Perhaps #undef the macro first, or do something like:
#if !defined
_WIN32_WINNT||_WIN32_WINNT<0x0601# undef _WIN32_WINNT # define _WIN32_WINNT 0x0601 #endif
Perhaps a better way is to avoid the WINNT stuff entirely and instead directly define the constant we actually care about. eg
#ifnef MAPVK_VK_TO_VSC
# define MAPVK_VK_TO_VSC 0 #endif
Regards,
Daniel
Signature · 4 lines
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|