From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40063) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eyf3L-0005So-DU for qemu-devel@nongnu.org; Wed, 21 Mar 2018 10:49:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eyf3K-00062C-Lf for qemu-devel@nongnu.org; Wed, 21 Mar 2018 10:49:23 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:57030 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eyf3K-00061x-HN for qemu-devel@nongnu.org; Wed, 21 Mar 2018 10:49:22 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C71814026788 for ; Wed, 21 Mar 2018 14:49:18 +0000 (UTC) References: <20180321134005.8822-1-marcandre.lureau@redhat.com> <20180321134005.8822-3-marcandre.lureau@redhat.com> <3ec274aa-0dea-0932-e560-f388c1cbac41@redhat.com> <4e876850-3057-e9d5-695b-69f4cde9aa9a@redhat.com> From: Paolo Bonzini Message-ID: <2467bc3b-c0da-b6e4-1201-48983ba5a5af@redhat.com> Date: Wed, 21 Mar 2018 15:49:13 +0100 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 2/3] qobject: assume base of a qobject is at offset 0 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?UTF-8?Q?Marc-Andr=c3=a9_Lureau?= , Eric Blake Cc: qemu-devel , "P. Berrange, Daniel" , "Armbruster, Markus" On 21/03/2018 15:21, Marc-Andr=C3=A9 Lureau wrote: >>> Yeah, I tried a few of those approaches. Here the problem is that >>> QObject doesn't have base field. So you get a compile time error with >>> a QObject * as argument. >> >> So the compiler requires &(x)->base to resolve even when it is not on = the >> branch that gets selected? >=20 > Unfortunately, yes, all branches must compile apparently (I know)... Ugh, and that's indeed true of _Generic too. These don't compile: struct s1 { int y; }; struct s2 { int z; }; #define f(x) _Generic(x, struct s1: (x).y, struct s2: (x).z) int f1(struct s1 *s) { return f(*s); } int f2(struct s2 *s) { return f(*s); } :( Then I guess Marc-Andr=C3=A9's realization is ugly but unavoidable. Paolo