[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 1/2] Add support for gcc format attribute gnu_pr
From: |
Blue Swirl |
Subject: |
Re: [Qemu-devel] [PATCH 1/2] Add support for gcc format attribute gnu_printf |
Date: |
Mon, 20 Sep 2010 19:18:53 +0000 |
On Mon, Sep 13, 2010 at 8:02 PM, Stefan Weil <address@hidden> 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 <address@hidden>
> ---
> 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.
- [Qemu-devel] [PATCH] mips_fulong2e: Detect format errors for function prom_set, Stefan Weil, 2010/09/11
- [Qemu-devel] [PATCH] mips_malta: Detect format errors for function prom_set, Stefan Weil, 2010/09/11
- [Qemu-devel] [PATCH 1/2] Add support for gcc format attribute gnu_printf, Stefan Weil, 2010/09/13
- Re: [Qemu-devel] [PATCH 1/2] Add support for gcc format attribute gnu_printf,
Blue Swirl <=
- [Qemu-devel] [PATCH] Move macros GCC_ATTR and GCC_FMT_ATTR to common header file, Stefan Weil, 2010/09/20
- [Qemu-devel] Re: [PATCH] Move macros GCC_ATTR and GCC_FMT_ATTR to common header file, Stefan Weil, 2010/09/21
- [Qemu-devel] [PATCH] Move macros GCC_ATTR and GCC_FMT_ATTR to common header file, Stefan Weil, 2010/09/21
- [Qemu-devel] Re: [PATCH] Move macros GCC_ATTR and GCC_FMT_ATTR to common header file, Blue Swirl, 2010/09/21
- [Qemu-devel] [PATCH] Move macros GCC_ATTR and GCC_FMT_ATTR to common header file, Stefan Weil, 2010/09/21
- [Qemu-devel] Re: [PATCH] Move macros GCC_ATTR and GCC_FMT_ATTR to common header file, Blue Swirl, 2010/09/22
- Re: [Qemu-devel] [PATCH 1/2] Add support for gcc format attribute gnu_printf, Stefan Weil, 2010/09/20
- [Qemu-devel] [PATCH 2/2] Use new gcc format attribute gnu_printf, Stefan Weil, 2010/09/13
- Re: [Qemu-devel] [PATCH] mips_malta: Detect format errors for function prom_set, Blue Swirl, 2010/09/20