All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jamie Lokier <jamie@shareable.org>
To: Sheng Yang <sheng@linux.intel.com>
Cc: "Kirill A. Shutemov" <kirill@shutemov.name>,
	Anthony Liguori <aliguori@us.ibm.com>,
	qemu-devel@nongnu.org, Juan Quintela <quintela@redhat.com>
Subject: Re: [Qemu-devel] "Enable _FORTIFY_SOURCE=2" result in building failure for qemu-img.c
Date: Thu, 4 Feb 2010 12:10:27 +0000	[thread overview]
Message-ID: <20100204121027.GA10297@shareable.org> (raw)
In-Reply-To: <201002041504.52626.sheng@linux.intel.com>

Sheng Yang wrote:
>     printf("qemu-img version " QEMU_VERSION ", Copyright (c) 2004-2008 Fabrice 
> Bellard\n"
>            "usage: qemu-img command [command options]\n"
>            "QEMU disk image utility\n"
>            "\n"
>            "Command syntax:\n"
> #define DEF(option, callback, arg_string)        \
>            "  " arg_string "\n"
> #include "qemu-img-cmds.h"
> #undef DEF
> #undef GEN_DOCS
> ....
> 
> Seems gcc take "printf" as a marco. I added a "#undef printf" before the line, 
> then it works...
> 
> So any clue on what's happened and how to fix?

You can't have preprocessor directives inside the arguments of a macro
call.  Yes it's occasionally annoying like this.

You can prevent the macro call without #undef by writing:

    (printf)("qemu-img version " ...etc)

I'm not sure if Glibc is compliant with ISO C by
making printf into a macro that takes arguments.

Certain functions such as putchar() are specified as being allowed to
be macros, which implies the other standard functions aren't.

-- Jamie

  parent reply	other threads:[~2010-02-04 12:10 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-04  7:04 [Qemu-devel] "Enable _FORTIFY_SOURCE=2" result in building failure for qemu-img.c Sheng Yang
2010-02-04 12:09 ` [Qemu-devel] " Paolo Bonzini
2010-02-04 12:10 ` Jamie Lokier [this message]
2010-02-04 17:52   ` [Qemu-devel] " Markus Armbruster
2010-02-04 12:31 ` [Qemu-devel] " Juan Quintela
2010-02-04 13:29   ` [Qemu-devel] [PATCH] qemu-img: avoid preprocessor directives in a printf call Paolo Bonzini
2010-02-04 15:13     ` [Qemu-devel] " Sheng Yang
2010-02-04 15:49       ` [Qemu-devel] [PATCH 0/4] Fix printf calls embedding preprocessor directives Paolo Bonzini
2010-02-05  2:26         ` [Qemu-devel] " Sheng Yang
2010-02-05  8:30           ` Kevin Wolf
2010-02-05  8:47           ` Paolo Bonzini
2010-02-04 15:49       ` [Qemu-devel] [PATCH 1/4] qemu-img: avoid preprocessor directives in a printf call Paolo Bonzini
2010-02-04 15:49       ` [Qemu-devel] [PATCH 2/4] cope with printf macro definition in readline.c Paolo Bonzini
2010-02-04 15:49       ` [Qemu-devel] [PATCH 3/4] do not interpolate % from vl.c to qemu-options.h Paolo Bonzini
2010-02-04 15:49       ` [Qemu-devel] [PATCH 4/4] vl.c: avoid preprocessor directives in a printf call Paolo Bonzini

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=20100204121027.GA10297@shareable.org \
    --to=jamie@shareable.org \
    --cc=aliguori@us.ibm.com \
    --cc=kirill@shutemov.name \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    --cc=sheng@linux.intel.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.