[Top][All Lists]

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

Re: [libvirt] [PATCH] Define __USE_MINGW_ANSI_STDIO in config.h

From: Eric Blake
Subject: Re: [libvirt] [PATCH] Define __USE_MINGW_ANSI_STDIO in config.h
Date: Mon, 08 Dec 2014 16:14:27 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0

On 12/02/2014 06:50 AM, Pádraig Brady wrote:
>>> >> GNULIB's 'asprintf' module detected that mingw had
>>> >> the asprintf function, but didn't define the
>>> >> __USE_MINGW_ANSI_STDIO so we got left with the version
>>> >> offering Win32 format specifiers, instead of GNU formats.
>>> >>
>>> >> It could perhaps be argued that gnulib's 'asprintf'
>>> >> could be defining __USE_MINGW_ANSI_STDIO for us ?
>> > 
>> > Yes, gnulib should be taking advantage of this new mingw development.
> I independently noticed this mingw feature when looking at the portability
> of gnulib's ftoastr to mingw.  I agree that gnulib should define this.
> Note ftoastr doesn't depend on any of the gnulib printf modules
> as that was thought to be overkill for the portability provided,
> so I'm not sure where to put this define.  In the attached I added
> it to the extensions module and depended on that from both ftoastr and stdio.

Phooey - with this patch, but NOT a full use of gnulib *printf modules,
I run into a new issue:

  CC       event_test-event-test.o
../../../examples/object-events/event-test.c: In function
../../../examples/object-events/event-test.c:329:12: error: unknown
conversion type character 'l' in format [-Werror=format=]

where the code in question is using:

    printf("%s EVENT: Domain %s(%d) rtc change %" PRIdMAX "\n",
           __func__, virDomainGetName(dom), virDomainGetID(dom),

Note that this compiled just fine without your patch.  It looks like the
difference is because gnulib's stdio.h replacement does:

#  if 0 || 0
_GL_FUNCDECL_RPL (fprintf, int, (FILE *fp, const char *format, ...)
                                _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
                                _GL_ARG_NONNULL ((1, 2)));
#  else
_GL_FUNCDECL_RPL (fprintf, int, (FILE *fp, const char *format, ...)
                                _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 3)
                                _GL_ARG_NONNULL ((1, 2)));
#  endif

where, if no fprintf module is used, then we are FORCING the system
printf format, so gcc thinks that %lld is unsupported - but at the same
time, mingw's <inttypes.h> has conditional logic that defines PRIdMAX to
"lld" instead of "I64d" when we have turned on proper printf.

It looks like we need to rethink the logic in stdio.h to unconditionally
use __gnu_printf__ when we are sure that the mingw define actually makes
a difference, so that the rest of the code base can just blindly use %lld.

Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]