[virt-tools-list] [PATCH 3/3] remote-viewer: allow to build with Microsoft Visual Studio

Francesco Giudici fgiudici at redhat.com
Tue Nov 12 11:29:12 UTC 2019


In order to meaningfully use the g_io_channel_win32_new_fd() function
the C runtime used by GLib is required, which is msvcrt.dll. In current
Microsoft compilers it is near impossible to convince it to build code
that would use msvcrt.dll. The last Microsoft compiler version that
supported using msvcrt.dll as the C runtime was version 6. The GNU
compiler and toolchain for Windows, also known as Mingw, fully supports
msvcrt.dll.
For this reason, drop the SIGINT handler when building with Microsoft
Visual Studio.

Signed-off-by: Francesco Giudici <fgiudici at redhat.com>
---
 src/virt-viewer-app.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c
index 6712e6a..357ec21 100644
--- a/src/virt-viewer-app.c
+++ b/src/virt-viewer-app.c
@@ -1757,6 +1757,7 @@ static gboolean opt_fullscreen = FALSE;
 static gboolean opt_kiosk = FALSE;
 static gboolean opt_kiosk_quit = FALSE;
 
+#ifndef _MSC_VER
 static int sigint_pipe[2];
 
 static void
@@ -1836,6 +1837,7 @@ sigint_cb(GIOChannel *source,
     g_io_channel_read_chars (source, &sbuf, 1, NULL, NULL);
     return TRUE;
 }
+#endif
 
 static void
 title_maybe_changed(VirtViewerApp *self, GParamSpec* pspec G_GNUC_UNUSED, gpointer user_data G_GNUC_UNUSED)
@@ -1847,12 +1849,15 @@ static void
 virt_viewer_app_init(VirtViewerApp *self)
 {
     GError *error = NULL;
+#ifndef _MSC_VER
     GIOChannel *sigint_channel = NULL;
+#endif
 
     self->priv = virt_viewer_app_get_instance_private(self);
 
     gtk_window_set_default_icon_name("virt-viewer");
 
+#ifndef _MSC_VER
     register_sigint_handler();
 #ifdef G_OS_WIN32
     sigint_channel = g_io_channel_win32_new_fd(sigint_pipe[0]);
@@ -1860,6 +1865,7 @@ virt_viewer_app_init(VirtViewerApp *self)
     sigint_channel = g_io_channel_unix_new(sigint_pipe[0]);
 #endif
     g_io_add_watch(sigint_channel, G_IO_IN, sigint_cb, self);
+#endif
 
     self->priv->displays = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, g_object_unref);
     self->priv->config = g_key_file_new();
-- 
2.21.0





More information about the virt-tools-list mailing list