From nobody Wed Apr 24 04:52:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1547196225308756.9948663261229; Fri, 11 Jan 2019 00:43:45 -0800 (PST) Received: from localhost ([127.0.0.1]:59035 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghsPo-0000eW-DD for importer@patchew.org; Fri, 11 Jan 2019 03:43:44 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52991) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghsOk-0000H8-6y for qemu-devel@nongnu.org; Fri, 11 Jan 2019 03:42:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ghsOj-0003Ez-CJ for qemu-devel@nongnu.org; Fri, 11 Jan 2019 03:42:38 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48472) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ghsOj-0003Aw-6q for qemu-devel@nongnu.org; Fri, 11 Jan 2019 03:42:37 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 382058E688; Fri, 11 Jan 2019 08:42:33 +0000 (UTC) Received: from thuth.com (ovpn-116-124.ams2.redhat.com [10.36.116.124]) by smtp.corp.redhat.com (Postfix) with ESMTP id 31F735D6A9; Fri, 11 Jan 2019 08:42:31 +0000 (UTC) From: Thomas Huth To: qemu-devel@nongnu.org Date: Fri, 11 Jan 2019 09:42:28 +0100 Message-Id: <1547196148-12250-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 11 Jan 2019 08:42:33 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] HACKING: Clarify the paragraph about typedefs X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, Greg Kurz , Markus Armbruster , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , pbonzini@redhat.com, "Dr. David Alan Gilbert" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The paragraph about typedefs is very sparse and caused some trouble already: Is this mandatory coding style or just a recommendation? ... since this is the HACKING file and not in CODING_STYLE. And various versions of GCC and Clang disallow duplicated typedefs in certain language modes, so the "enforced" typedeffing repeatedly caused compile errors in the past. Thus let's reword this paragraph a little bit, so that it is clear that typedefs are welcome, but not a mandatory coding style. Also add some information about our include/qemu/typedefs.h file here since most newcomers are not aware of this file yet. Signed-off-by: Thomas Huth --- HACKING | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/HACKING b/HACKING index 0fc3e0f..aa6fc3f 100644 --- a/HACKING +++ b/HACKING @@ -100,7 +100,13 @@ pointer, you're guaranteed that it is used to modify t= he storage it points to, or it is aliased to another pointer that is. =20 2.3. Typedefs -Typedefs are used to eliminate the redundant 'struct' keyword. +Typedefs can be used to eliminate the redundant 'struct' keyword. This is +especially helpful for common types that are used all over the place. Since +certain C compilers choke on duplicated typedefs, you should avoid them and +declare a typedef only in one header file. For common types, you can use +"include/qemu/typedefs.h" for example. Note that it is also perfectly fine= to +use forward struct definitions without typedefs for references in headers +to avoid the problem with duplicated typedefs. =20 2.4. Reserved namespaces in C and POSIX Underscore capital, double underscore, and underscore 't' suffixes should = be --=20 1.8.3.1