From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=42231 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ole7F-0002Bx-Rc for qemu-devel@nongnu.org; Wed, 18 Aug 2010 04:35:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Ole7E-00064o-LZ for qemu-devel@nongnu.org; Wed, 18 Aug 2010 04:35:21 -0400 Received: from mail-qw0-f45.google.com ([209.85.216.45]:44342) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Ole7E-00064k-IC for qemu-devel@nongnu.org; Wed, 18 Aug 2010 04:35:20 -0400 Received: by qwh5 with SMTP id 5so236267qwh.4 for ; Wed, 18 Aug 2010 01:35:20 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <4C6B9B44.7020803@redhat.com> Date: Wed, 18 Aug 2010 10:35:16 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <4C6A43B5.40809@redhat.com> <4C6AD744.1070009@twiddle.net> In-Reply-To: <4C6AD744.1070009@twiddle.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [PATCH 2/5] CODING_STYLE: add C type rules List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Richard Henderson Cc: Blue Swirl , Jes Sorensen , qemu-devel On 08/17/2010 08:39 PM, Richard Henderson wrote: >> On 08/12/10 19:50, Blue Swirl wrote: >>> +While using "bool" is good for readability, it comes with minor caveats: >>> + - Don't use "bool" in places where the type size must be constant across >>> + all systems, like public interfaces and on-the-wire protocols. >>> + - Don't compare a bool variable against the literal, "true", >>> + since a value with a logical non-false value need not be "1". >>> + I.e., don't write "if (seen == true) ...". Rather, write "if (seen)...". >> >> I'd strongly discourage the use of bool in any code. > > I strongly disagree. The use of "bool", even if you ignore stdbool.h > and do "typedef int bool", is valuable documentation in the code. I think "bool" is fine, but it should be either stdbool.h or a typedef. Using stdbool.h only when it is present is going to introduce bugs the day someone relies on the magic properties of the C99 bool. Paolo