Received: from eggs.gnu.org ([2001:4830:134:3::10]:41136) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bNEw6-0001sj-Nn for qemu-devel@nongnu.org; Wed, 13 Jul 2016 03:50:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bNEw5-0005yD-Pc for qemu-devel@nongnu.org; Wed, 13 Jul 2016 03:50:26 -0400 From: Markus Armbruster References: <1468336912-20396-1-git-send-email-eblake@redhat.com> <578535BC.3000904@redhat.com> Date: Wed, 13 Jul 2016 09:50:18 +0200 In-Reply-To: (Peter Maydell's message of "Tue, 12 Jul 2016 20:35:26 +0100") Message-ID: <87inwa7z9h.fsf@dusky.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] build: Work around SIZE_MAX bug in OSX headers List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: Eric Blake , Kevin Wolf , QEMU Developers , Qemu-block Peter Maydell writes: > On 12 July 2016 at 19:23, Eric Blake wrote: >> This violates POSIX, which requires that: >> http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/stdint.h.html#t= ag_13_48 >> "Each instance of these macros shall be replaced by a constant >> expression suitable for use in #if preprocessing directives, and this >> expression shall have the same type as would an expression that is an >> object of the corresponding type converted according to the integer >> promotions." >> >> That is, it is valid C to write '#if SIZE_MAX =3D=3D 0xffffffff', while = my >> replacement fails that test: >> >> foo.c:6:26: error: missing binary operator before token "(" >> #define SIZE_MAX ((sizeof(char)) * -1) >> ^ >> foo.c:7:5: note: in expansion of macro =E2=80=98SIZE_MAX=E2=80=99 > > I tested this patch with a compile on OSX, and it does compile > without warnings or errors. (NB: haven't tested that it > fixes the warning that was being complained about in the > other patchset.) > > I don't have a very strong opinion about whether it's the > best fix, but a couple of thoughts: > * my inclination is to prefer not to override system > headers except where we've checked and know they're broken > (ie in a future world where Apple get their headers right > I'd rather we automatically ended up using their version > rather than ours) That's a good point. > * we don't have any #if ...SIZE_MAX, but we do have some > for other kinds of _MAX constant.