From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60006) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYt6y-0007UF-7I for qemu-devel@nongnu.org; Mon, 07 Sep 2015 05:53:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZYt6x-0006Ji-By for qemu-devel@nongnu.org; Mon, 07 Sep 2015 05:53:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57048) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYt6x-0006Je-6I for qemu-devel@nongnu.org; Mon, 07 Sep 2015 05:53:15 -0400 From: Paolo Bonzini Date: Mon, 7 Sep 2015 11:53:01 +0200 Message-Id: <1441619584-17992-2-git-send-email-pbonzini@redhat.com> In-Reply-To: <1441619584-17992-1-git-send-email-pbonzini@redhat.com> References: <1441619584-17992-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 1/4] CODING_STYLE: update mixed declaration rules List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Andreas Faerber , Eduardo Habkost , Markus Armbruster Mixed declarations also do exist at the top of #ifdef blocks. Reluctantly allow this particular usage and suggest an alternative. Signed-off-by: Paolo Bonzini --- CODING_STYLE | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/CODING_STYLE b/CODING_STYLE index d46cfa5..3c6978f 100644 --- a/CODING_STYLE +++ b/CODING_STYLE @@ -87,10 +87,15 @@ Furthermore, it is the QEMU coding style. 5. Declarations -Mixed declarations (interleaving statements and declarations within blocks) -are not allowed; declarations should be at the beginning of blocks. In other -words, the code should not generate warnings if using GCC's --Wdeclaration-after-statement option. +Mixed declarations (interleaving statements and declarations within +blocks) are generally not allowed; declarations should be at the beginning +of blocks. + +Every now and then, an exception is made for declarations inside a +#ifdef or #ifndef block: if the code looks nicer, such declarations can +be placed at the top of the block even if there are statements above. +On the other hand, however, it's often best to move that #ifdef/#ifndef +block to a separate function altogether. 6. Conditional statements -- 2.4.3