All of lore.kernel.org
 help / color / mirror / Atom feed
From: phind.uet@gmail.com
To: "Paolo Bonzini" <pbonzini@redhat.com>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Daniel P. Berrangé" <berrange@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Kostiantyn Kostiuk" <kkostiuk@redhat.com>,
	"Michael Roth" <michael.roth@amd.com>
Cc: Nguyen Dinh Phi <phind.uet@gmail.com>, qemu-devel@nongnu.org
Subject: [PATCH 1/2] qga/vss-win32: Fix ConvertStringToBSTR redefinition with newer MinGW
Date: Tue, 16 Dec 2025 00:45:11 +0800	[thread overview]
Message-ID: <20251215164512.322786-2-phind.uet@gmail.com> (raw)
In-Reply-To: <20251215164512.322786-1-phind.uet@gmail.com>

From: Nguyen Dinh Phi <phind.uet@gmail.com>

Newer versions of MinGW-w64 provide ConvertStringToBSTR() in the
_com_util namespace via <comutil.h>. This causes a redefinition
error when building qemu-ga on Windows with these toolchains.

Add a meson check to detect whether ConvertStringToBSTR is already
available, and conditionally compile our fallback implementation
only when the system does not provide one.

Signed-off-by: Nguyen Dinh Phi <phind.uet@gmail.com>
---
 meson.build               | 12 ++++++++++++
 qga/vss-win32/install.cpp |  2 ++
 2 files changed, 14 insertions(+)

diff --git a/meson.build b/meson.build
index c5710a6a47..60a980e610 100644
--- a/meson.build
+++ b/meson.build
@@ -3299,6 +3299,18 @@ endif
 # Detect host pointer size for the target configuration loop.
 host_long_bits = cc.sizeof('void *') * 8
 
+# Detect if ConvertStringToBSTR has been defined in _com_util namespace
+if host_os == 'windows'
+  has_convert_string_to_bstr = cxx.compiles('''
+    #include <comutil.h>
+    int main() {
+        BSTR b = _com_util::ConvertStringToBSTR("test");
+        return b ? 0 : 1;
+    }
+  ''')
+  config_host_data.set('CONFIG_CONVERT_STRING_TO_BSTR', has_convert_string_to_bstr)
+endif
+
 ########################
 # Target configuration #
 ########################
diff --git a/qga/vss-win32/install.cpp b/qga/vss-win32/install.cpp
index 7b25d9098b..5b7a8e9bc5 100644
--- a/qga/vss-win32/install.cpp
+++ b/qga/vss-win32/install.cpp
@@ -549,6 +549,7 @@ STDAPI DllUnregisterServer(void)
 
 
 /* Support function to convert ASCII string into BSTR (used in _bstr_t) */
+#ifndef CONFIG_CONVERT_STRING_TO_BSTR
 namespace _com_util
 {
     BSTR WINAPI ConvertStringToBSTR(const char *ascii) {
@@ -566,6 +567,7 @@ namespace _com_util
         return bstr;
     }
 }
+#endif
 
 /* Stop QGA VSS provider service using Winsvc API  */
 STDAPI StopService(void)
-- 
2.43.0



  reply	other threads:[~2025-12-15 16:57 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-15 16:45 [PATCH 0/2] Fix Windows build issues with newer MinGW phind.uet
2025-12-15 16:45 ` phind.uet [this message]
2025-12-16  6:26   ` [PATCH 1/2] qga/vss-win32: Fix ConvertStringToBSTR redefinition " Marc-André Lureau
2025-12-16  9:53     ` Kostiantyn Kostiuk
2025-12-17 18:13       ` Pierrick Bouvier
2025-12-18  6:00         ` NGUYEN DINH PHI
2025-12-16 23:00   ` Pierrick Bouvier
2025-12-15 16:45 ` [PATCH 2/2] util: Move qemu_ftruncate64 from block/file-win32.c to oslib-win32.c phind.uet
2025-12-15 17:33   ` Philippe Mathieu-Daudé
2025-12-16 23:00   ` Pierrick Bouvier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251215164512.322786-2-phind.uet@gmail.com \
    --to=phind.uet@gmail.com \
    --cc=berrange@redhat.com \
    --cc=kkostiuk@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=michael.roth@amd.com \
    --cc=pbonzini@redhat.com \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.