Skip to contentSkip to conversation

curses: Fix compiler warnings (Mingw-w64 redefinition of macro KEY_EVENT)

PATCH In review Stefan Weil 2 participants 2 messages Nov 19, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 curses: Fix compiler warnings (Mingw-w64 redefinition of macro KEY_EVENT)

For builds with Mingw-w64 as it is included in Cygwin, there are two header files which define KEY_EVENT with different values.

This results in lots of compiler warnings like this one:

CC vl.o
In file included from /qemu/include/ui/console.h:340:0,

                 from /qemu/vl.c:76:

/usr/i686-w64-mingw32/sys-root/mingw/include/curses.h:1522:0: warning: "KEY_EVENT" redefined
#define KEY_EVENT 0633 /* We were interrupted by an event */

In file included from /usr/share/mingw-w64/include/windows.h:74:0,

                 from /usr/share/mingw-w64/include/winsock2.h:23,
                 from /qemu/include/sysemu/os-win32.h:29,
                 from /qemu/include/qemu/osdep.h:100,
                 from /qemu/vl.c:24:

/usr/share/mingw-w64/include/wincon.h:101:0: note: this is the location of the previous definition
#define KEY_EVENT 0x1

QEMU only uses the KEY_EVENT macro from wincon.h. Therefore we can undefine the macro coming from curses.h.

The explicit include statement for curses.h in ui/curses.c is not needed and was removed.

Those two modifications fix the redefinition warnings.

---
 include/ui/console.h | 3 +++
 ui/curses.c          | 1 -
 2 files changed, 3 insertions(+), 1 deletion(-)
include/ui/console.h +3 -0
index e2589e2..e5ae506 100644
@@ -337,7 +337,10 @@ static inline pixman_format_code_t surface_format(DisplaySurface *s)
 }
 
 #ifdef CONFIG_CURSES
+/* KEY_EVENT is defined in wincon.h and in curses.h. Avoid redefinition. */
+#undef KEY_EVENT
 #include <curses.h>
+#undef KEY_EVENT
 typedef chtype console_ch_t;
 extern chtype vga_to_curses[];
 #else
ui/curses.c +0 -1
index 2e132a7..03cefdf 100644
@@ -22,7 +22,6 @@
  * THE SOFTWARE.
  */
 #include "qemu/osdep.h"
-#include <curses.h>
 
 #ifndef _WIN32
 #include <sys/ioctl.h>
Signature · 1 line
2.10.2
Acked-by on v1 1/1
#1 lore raw
Quoted 22 lines · Stefan Weil, on Sat 19 Nov 2016 19:53:18 +0100, wrote:

For builds with Mingw-w64 as it is included in Cygwin, there are two header files which define KEY_EVENT with different values.

This results in lots of compiler warnings like this one:

CC vl.o
In file included from /qemu/include/ui/console.h:340:0,

                 from /qemu/vl.c:76:

/usr/i686-w64-mingw32/sys-root/mingw/include/curses.h:1522:0: warning: "KEY_EVENT" redefined
#define KEY_EVENT 0633 /* We were interrupted by an event */

In file included from /usr/share/mingw-w64/include/windows.h:74:0,

                 from /usr/share/mingw-w64/include/winsock2.h:23,
                 from /qemu/include/sysemu/os-win32.h:29,
                 from /qemu/include/qemu/osdep.h:100,
                 from /qemu/vl.c:24:

/usr/share/mingw-w64/include/wincon.h:101:0: note: this is the location of the previous definition
#define KEY_EVENT 0x1

QEMU only uses the KEY_EVENT macro from wincon.h. Therefore we can undefine the macro coming from curses.h.

Quoted 6 lines

The explicit include statement for curses.h in ui/curses.c is not needed and was removed.

Those two modifications fix the redefinition warnings.

Quoted 36 lines
---
 include/ui/console.h | 3 +++
 ui/curses.c          | 1 -
 2 files changed, 3 insertions(+), 1 deletion(-)
include/ui/console.h +3 -0
index e2589e2..e5ae506 100644
@@ -337,7 +337,10 @@ static inline pixman_format_code_t surface_format(DisplaySurface *s)
 }
 
 #ifdef CONFIG_CURSES
+/* KEY_EVENT is defined in wincon.h and in curses.h. Avoid redefinition. */
+#undef KEY_EVENT
 #include <curses.h>
+#undef KEY_EVENT
 typedef chtype console_ch_t;
 extern chtype vga_to_curses[];
 #else
ui/curses.c +0 -1
index 2e132a7..03cefdf 100644
@@ -22,7 +22,6 @@
  * THE SOFTWARE.
  */
 #include "qemu/osdep.h"
-#include <curses.h>
 
 #ifndef _WIN32
 #include <sys/ioctl.h>
Signature · 1 line
2.10.2
Signature · 6 lines
Samuel
Now I know someone out there is going to claim, "Well then, UNIX is intuitive,
because you only need to learn 5000 commands, and then everything else follows
from that! Har har har!"
(Andy Bates in comp.os.linux.misc, on "intuitive interfaces", slightly
defending Macs.)