From: Stefan Weil <weil@mail.berlios.de>
To: Blue Swirl <blauwirbel@gmail.com>
Cc: QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH 1/2] Add support for gcc format attribute gnu_printf
Date: Mon, 20 Sep 2010 23:03:49 +0200 [thread overview]
Message-ID: <4C97CC35.3080202@mail.berlios.de> (raw)
In-Reply-To: <AANLkTi=cnXfrCxiW6LapJHrzceTWV_084eZcxpRR+6=r@mail.gmail.com>
Am 20.09.2010 21:18, schrieb Blue Swirl:
> On Mon, Sep 13, 2010 at 8:02 PM, Stefan Weil<weil@mail.berlios.de> wrote:
>
>> Since version 4.4.x, gcc supports additional format attributes.
>> __attribute__ ((format (gnu_printf, 1, 2)))
>> should be used instead of
>> __attribute__ ((format (printf, 1, 2))
>> because QEMU always uses standard format strings (even with mingw32).
>>
>> For older compilers, we simply define gnu_printf = printf,
>> so they work with the new format attribute, too.
>>
>> Signed-off-by: Stefan Weil<weil@mail.berlios.de>
>> ---
>> configure | 11 +++++++++++
>> 1 files changed, 11 insertions(+), 0 deletions(-)
>>
>> diff --git a/configure b/configure
>> index 4061cb7..1300879 100755
>> --- a/configure
>> +++ b/configure
>> @@ -148,6 +148,17 @@ for flag in $gcc_flags; do
>> fi
>> done
>>
>> +# Check gnu_printf (supported by gcc>= 4.4.x).
>> +cat> $TMPC<< EOF
>> +static void test(const char *format, ...)
>> + __attribute__ ((format (gnu_printf, 1, 2)));
>> +static void test(const char *format, ...) {}
>> +int main(void) { test("\n"); return 0; }
>> +EOF
>> +if ! compile_prog "-Werror" ""; then
>> + QEMU_CFLAGS="-Dgnu_printf=printf $QEMU_CFLAGS"
>>
> This could cause problems, for example if system headers declared a
> function called gnu_printf.
>
> I'd introduce CONFIG_GCC_FMT_ATTR_GNU_PRINTF and adjust GCC_FMT_ATTR
> definition based on that.
>
>
Thanks for your review. I'll send a new patch which goes
into the direction which you suggested.
Instead of defining a new macro CONFIG_GCC_FMT_ATTR_GNU_PRINTF,
my new patch checks the gcc version (gnu_printf was introduced
with gcc 4.4). Like this, no changes to file configure are needed.
Regards
Stefan
next prev parent reply other threads:[~2010-09-20 21:16 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-11 6:46 [Qemu-devel] [PATCH] mips_fulong2e: Detect format errors for function prom_set Stefan Weil
2010-09-11 6:46 ` [Qemu-devel] [PATCH] mips_malta: " Stefan Weil
2010-09-13 20:02 ` [Qemu-devel] [PATCH 1/2] Add support for gcc format attribute gnu_printf Stefan Weil
2010-09-20 19:18 ` Blue Swirl
2010-09-20 21:03 ` Stefan Weil [this message]
2010-09-20 21:05 ` [Qemu-devel] [PATCH] Move macros GCC_ATTR and GCC_FMT_ATTR to common header file Stefan Weil
2010-09-21 17:46 ` [Qemu-devel] " Stefan Weil
2010-09-21 17:48 ` [Qemu-devel] " Stefan Weil
2010-09-21 18:17 ` [Qemu-devel] " Blue Swirl
2010-09-21 20:27 ` [Qemu-devel] " Stefan Weil
2010-09-22 20:30 ` [Qemu-devel] " Blue Swirl
2010-09-13 20:02 ` [Qemu-devel] [PATCH 2/2] Use new gcc format attribute gnu_printf Stefan Weil
2010-09-20 18:53 ` Blue Swirl
2010-09-20 19:04 ` [Qemu-devel] [PATCH] mips_malta: Detect format errors for function prom_set Blue Swirl
2010-09-20 19:03 ` [Qemu-devel] [PATCH] mips_fulong2e: " Blue Swirl
2010-09-20 20:18 ` [Qemu-devel] [PATCH 1/2] mips_fulong2e: Fix format strings Stefan Weil
2010-09-21 19:48 ` [Qemu-devel] " Blue Swirl
2010-09-20 20:18 ` [Qemu-devel] [PATCH 2/2] mips_malta: " Stefan Weil
2010-09-21 19:48 ` [Qemu-devel] " Blue Swirl
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=4C97CC35.3080202@mail.berlios.de \
--to=weil@mail.berlios.de \
--cc=blauwirbel@gmail.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).