From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N0GqT-0005Wd-Oa for qemu-devel@nongnu.org; Tue, 20 Oct 2009 11:41:57 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N0GqO-0005Ub-70 for qemu-devel@nongnu.org; Tue, 20 Oct 2009 11:41:56 -0400 Received: from [199.232.76.173] (port=47098 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N0GqO-0005UT-3w for qemu-devel@nongnu.org; Tue, 20 Oct 2009 11:41:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:12961) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N0GqN-0004V0-I2 for qemu-devel@nongnu.org; Tue, 20 Oct 2009 11:41:51 -0400 Message-ID: <4ADDDA3C.40407@redhat.com> Date: Tue, 20 Oct 2009 17:41:48 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <20091019191504.GA8157@shareable.org> In-Reply-To: <20091019191504.GA8157@shareable.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [PATCH 00/25] VMState cleanups and conversion of network drivers List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jamie Lokier Cc: qemu-devel@nongnu.org, Juan Quintela On 10/19/2009 09:15 PM, Jamie Lokier wrote: > __builtin_types_compatible_p(), __builtin_choose_exper and > __attribute__((__error__)) are good for informative error messages. Unfortunately __attribute__((__error__)) cannot be applied in this case for several reasons: 1) it cannot apply to types so you cannot do extern void compile_error (void); #define raise_compile_error(x) \ (((void __attribute__ ((error(x))) (*) (void)) x) ()) 2) it only operates for calls, so you cannot use it in initializers I whipped up a patch to add to GCC __builtin_compile_error, to be used inside __builtin_choose_expr: #define typecheck(t1, t2) \ __builtin_choose_expr (__builtin_types_compatible(t1, t2), (void)0, \ __builtin_compile_error (#t1 " and " #t2 \ "are not compatible types")) #define if_types_compatible(t1, t2, value) (typecheck (t1, t2), value) and I will send it upstream, but it will be a long time before it is in a released version (especially since GCC is currently in bug-fixing-only mode)---anyway Jamie got the array case to work, AFAIU. Paolo