qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
To: Stefan Hajnoczi <stefanha@gmail.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] rewrite QEMU_BUILD_BUG_ON
Date: Tue, 20 Dec 2011 18:47:47 +0800	[thread overview]
Message-ID: <4EF067D3.2010103@linux.vnet.ibm.com> (raw)
In-Reply-To: <20111220101343.GC10603@stefanha-thinkpad.localdomain>

于 2011年12月20日 18:13, Stefan Hajnoczi 写道:
> On Tue, Dec 20, 2011 at 05:03:47PM +0800, Dong Xu Wang wrote:
>> From: Dong Xu Wang<wdongxu@linux.vnet.ibm.com>
>>
>> On some platforms, __LINE__ will not expand to real number in QEMU_BUILD_BUG_ON,
>> so if using QEMU_BUILD_BUG_ON twice, compiler will report errors. This patch will
>> fix it.
>>
>> BTW, I got error message on RHEL 6.1/gcc 4.4.5.
>
> Can you post the gcc -E output of the file that produces the error as
> well as the gcc error output?
>
> Stefan
>
>

I doubled the following lines in block/qcow2-snapshot.c(line 211 and 212):

QEMU_BUILD_BUG_ON(offsetof(QCowHeader, snapshots_offset) !=
offsetof(QCowHeader, nb_snapshots) + sizeof(header_data.nb_snapshots));"


While "gcc -E -C -I. block/qcow2-snapshot.c", I can get:
typedef char
  qemu_build_bug_on____LINE__
# 241 "block/qcow2-snapshot.c"
     [(__builtin_offsetof (QCowHeader, snapshots_offset) != 
__builtin_offsetof (QCowHeader, nb_snapshots) + 
sizeof(header_data.nb_snapshots))?-1:1];
 
        ;
   typedef char
  qemu_build_bug_on____LINE__
# 243 "block/qcow2-snapshot.c"
   [(__builtin_offsetof (QCowHeader, snapshots_offset) != 
__builtin_offsetof (QCowHeader, nb_snapshots) + 
sizeof(header_data.nb_snapshots))?-1:1];

__LINE__ are not expanded to real line number.



While normally compiling, error message is:
   CC    block/qcow2-snapshot.o
block/qcow2-snapshot.c: In function \u2018qcow2_write_snapshots\u2019:
block/qcow2-snapshot.c:244: error: redefinition of typedef 
\u2018qemu_build_bug_on____LINE__\u2019
block/qcow2-snapshot.c:242: note: previous declaration of 
\u2018qemu_build_bug_on____LINE__\u2019 was here
make: *** [block/qcow2-snapshot.o] Error 1

  reply	other threads:[~2011-12-20 10:48 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-20  9:03 [Qemu-devel] [PATCH] rewrite QEMU_BUILD_BUG_ON Dong Xu Wang
2011-12-20 10:13 ` Stefan Hajnoczi
2011-12-20 10:47   ` Dong Xu Wang [this message]
2011-12-20 12:08     ` Stefan Hajnoczi
2011-12-20 13:12       ` Dong Xu Wang
2011-12-20 13:41         ` Stefan Hajnoczi
2012-01-09  5:26           ` Dong Xu Wang
2012-02-08 12:49 ` Kevin Wolf

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=4EF067D3.2010103@linux.vnet.ibm.com \
    --to=wdongxu@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.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 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).