Re: [PATCH] Fix MinGW build

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 09/24/2014 05:13 PM, Martin Kletzander wrote:
On Wed, Sep 24, 2014 at 02:13:25PM +0200, Pavel Hrdina wrote:
When building on mingw the format string for long long/unsigned long
long have to be I64d/I64u instead of lld/llu.

Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx>
---

I'm not sure if this is the right way to do it so sending it for review.


I think this is OK since it's still partly build-breaker.  We can
change it later.

examples/object-events/event-test.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/examples/object-events/event-test.c
b/examples/object-events/event-test.c
index 9e09736..e90b590 100644
--- a/examples/object-events/event-test.c
+++ b/examples/object-events/event-test.c
@@ -476,6 +476,15 @@ myDomainEventTunableCallback(virConnectPtr conn
ATTRIBUTE_UNUSED,
    printf("%s EVENT: Domain %s(%d) tunable updated:\n",
           __func__, virDomainGetName(dom), virDomainGetID(dom));

+#ifdef WIN32
+/* MinGW doesn't know the lld/llu so we have to use I64f/I64u
instead. */
+# define LLD_FORMAT "%I64d"
+# define LLU_FORMAT "%I64u"
+#else /* WIN32 */
+# define LLD_FORMAT "%lld"
+# define LLU_FORMAT "%llu"
+#endif /* WIN32 */
+
    for (i = 0; i < nparams; i++) {
        switch (params[i].type) {
        case VIR_TYPED_PARAM_INT:
@@ -485,10 +494,10 @@ myDomainEventTunableCallback(virConnectPtr conn
ATTRIBUTE_UNUSED,
            printf("\t%s: %u\n", params[i].field, params[i].value.ui);
            break;
        case VIR_TYPED_PARAM_LLONG:
-            printf("\t%s: %lld\n", params[i].field, params[i].value.l);
+            printf("\t%s: "LLD_FORMAT"\n", params[i].field,
params[i].value.l);
            break;
        case VIR_TYPED_PARAM_ULLONG:
-            printf("\t%s: %llu\n", params[i].field, params[i].value.ul);
+            printf("\t%s: "LLU_FORMAT"\n", params[i].field,
params[i].value.ul);

ACK if you put space around the macros.

Martin

Updated and pushed, thanks.

Pavel

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]