From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:43057) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TDQzu-0005fY-Nc for qemu-devel@nongnu.org; Sun, 16 Sep 2012 22:23:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TDQzt-0004yj-CT for qemu-devel@nongnu.org; Sun, 16 Sep 2012 22:23:42 -0400 Received: from e23smtp08.au.ibm.com ([202.81.31.141]:36709) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TDQzs-0004yP-P5 for qemu-devel@nongnu.org; Sun, 16 Sep 2012 22:23:41 -0400 Received: from /spool/local by e23smtp08.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 17 Sep 2012 12:23:01 +1000 Received: from d23av01.au.ibm.com (d23av01.au.ibm.com [9.190.234.96]) by d23relay04.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q8H2EAvU15007964 for ; Mon, 17 Sep 2012 12:14:11 +1000 Received: from d23av01.au.ibm.com (loopback [127.0.0.1]) by d23av01.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q8H2NMgB003474 for ; Mon, 17 Sep 2012 12:23:23 +1000 Message-ID: <50568990.6070409@linux.vnet.ibm.com> Date: Mon, 17 Sep 2012 10:23:12 +0800 From: Wenchao Xia MIME-Version: 1.0 References: <1347265586-17698-1-git-send-email-xiawenc@linux.vnet.ibm.com> <1347265586-17698-3-git-send-email-xiawenc@linux.vnet.ibm.com> <504FC0B1.7080903@redhat.com> <504FFC05.5070601@linux.vnet.ibm.com> <5050874B.4050505@redhat.com> <505151D8.9030300@linux.vnet.ibm.com> <50515406.8020203@redhat.com> <505157CD.2080703@redhat.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH V2 2/6] libqblock type and structure defines List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Blue Swirl Cc: kwolf@redhat.com, aliguori@us.ibm.com, stefanha@gmail.com, qemu-devel@nongnu.org, pbonzini@redhat.com, Eric Blake 于 2012-9-15 2:11, Blue Swirl 写道: > On Thu, Sep 13, 2012 at 3:49 AM, Eric Blake wrote: >> On 09/12/2012 09:33 PM, Eric Blake wrote: >>>> OK ,then I think >>>> #if __GNUC__ >= 4 >>>> .... >>>> #else >>>> [warn name space pollution may happen] >>>> #endif >>>> would be better. >>> >>> It may be shorter, but it is definitely not better, at least not in the >>> current context of qemu. Using the short form will fail a -Werror >>> build, unless you also write a patch to qemu's configure to quit >>> supplying -Wundef during builds. But as touching configure has a bigger >>> impact to the overall qemu project, you're going to need a lot more >>> buy-in from other developers that -Wundef is not helping qemu gain any >>> portability, and that it is safe to ditch it (or get enough >>> counter-arguments from other developers why qemu insists on the >>> anachronistic style enforced by -Wundef, at which point you must comply >>> and use the longer form). >> >> On second thought, this _particular_ usage will never fail a -Wundef >> -Werror build, precisely because -Wundef is a gcc warning, which impies >> the warning is only ever useful in the same scenarios that the __GNUC__ >> macro is always defined (that is, __GNUC__ is undefined only on a >> non-gcc compiler, but what non-gcc compiler supports -Wundef -Werror?). > > The library could be used by a project that does not use GCC or pick > CFLAGS from QEMU configuration. Supporting for example MSVC or C++ > users for the library could be interesting one day, even if we didn't > support MSVC or C++ at all for building the rest of QEMU. > Each compiler would have its own predefined macro, so I think now I can just support gcc and give a warning when gcc not found. If more compiler is needed, extend the macro in the future. >> >> But why should this line be the one exemption to the rules? Either qemu >> insists on the -Wundef style of coding (and you should use the long form >> to conform to that style, on the off-chance that someone ever wants to >> port to a non-gcc compiler, even in this one place where gcc can't warn >> you about the violation of that style), or we should change the qemu >> style (at which point, the short form is nicer here, but it also implies >> the potential for cleaning up lots of other places to also use short >> forms and rely on preprocessor 0 computation). >> >> -- >> Eric Blake eblake@redhat.com +1-919-301-3266 >> Libvirt virtualization library http://libvirt.org >> > -- Best Regards Wenchao Xia