|
From: | Wenchao Xia |
Subject: | Re: [Qemu-devel] [PATCH V2 2/6] libqblock type and structure defines |
Date: | Mon, 17 Sep 2012 10:23:12 +0800 |
User-agent: | Mozilla/5.0 (Windows NT 5.1; rv:15.0) Gecko/20120907 Thunderbird/15.0.1 |
δΊ 2012-9-15 2:11, Blue Swirl ει:
On Thu, Sep 13, 2012 at 3:49 AM, Eric Blake <address@hidden> 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 address@hidden +1-919-301-3266 Libvirt virtualization library http://libvirt.org
-- Best Regards Wenchao Xia
[Prev in Thread] | Current Thread | [Next in Thread] |