From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=55262 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Oxniu-0002x5-SQ for qemu-devel@nongnu.org; Mon, 20 Sep 2010 17:16:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OxnWl-0005TE-Oy for qemu-devel@nongnu.org; Mon, 20 Sep 2010 17:03:57 -0400 Received: from moutng.kundenserver.de ([212.227.17.10]:49992) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OxnWl-0005SM-C3 for qemu-devel@nongnu.org; Mon, 20 Sep 2010 17:03:55 -0400 Message-ID: <4C97CC35.3080202@mail.berlios.de> Date: Mon, 20 Sep 2010 23:03:49 +0200 From: Stefan Weil MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH 1/2] Add support for gcc format attribute gnu_printf References: <1284187585-20953-2-git-send-email-weil@mail.berlios.de> <1284408157-17276-1-git-send-email-weil@mail.berlios.de> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Blue Swirl Cc: QEMU Developers Am 20.09.2010 21:18, schrieb Blue Swirl: > On Mon, Sep 13, 2010 at 8:02 PM, Stefan Weil 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 >> --- >> 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