From nobody Tue Feb 10 06:27:14 2026 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 ARC-Seal: i=1; a=rsa-sha256; t=1566286132; cv=none; d=zoho.com; s=zohoarc; b=INJbziHV2ZABo/raCsnVTmE6gZnshgmOflPZiYK9jK3/rbdlqAtEyvniKmJdvdgqBiWAz3+w07+gD2bUU9mEM6OjM4VdfCtP7gkmeH0e9Ui58ELeQduXs8FHbNeXgfdX4lE0lw8CYyseMwgStQCN0f+WVgp87Lqjac1zLMr1lqQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566286132; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=WhmTS3WChxS/JFOIqtb+uQKEHXnXCRf9c+j47txMe1o=; b=iHiF6yUF/PZa9j3Qi31LrD2UnIWLtxYMwuPevqOBtnCdRJinJhUcwDxgbyTjGUvPY5JyVGEXeAEC9/381cIKeQlUqz0YaQpluFefen0KSHxi+lqnnYtQvzBicTdNBl8HuP3Ua4AeqBsYQTF50Nohaeh0jWslul/VPPok1wAVsMs= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1566286132597208.3696716183963; Tue, 20 Aug 2019 00:28:52 -0700 (PDT) Received: from localhost ([::1]:34128 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzyZX-0007Zf-Gm for importer@patchew.org; Tue, 20 Aug 2019 03:28:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42913) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzy92-00063p-St for qemu-devel@nongnu.org; Tue, 20 Aug 2019 03:01:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hzy8x-0003pB-Fr for qemu-devel@nongnu.org; Tue, 20 Aug 2019 03:01:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37758) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hzy8u-0003f8-EY for qemu-devel@nongnu.org; Tue, 20 Aug 2019 03:01:20 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B04333001836 for ; Tue, 20 Aug 2019 07:01:12 +0000 (UTC) Received: from 640k.localdomain.com (ovpn-112-20.ams2.redhat.com [10.36.112.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id AAF5560F88; Tue, 20 Aug 2019 07:01:11 +0000 (UTC) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 20 Aug 2019 08:59:51 +0200 Message-Id: <1566284395-30287-33-git-send-email-pbonzini@redhat.com> In-Reply-To: <1566284395-30287-1-git-send-email-pbonzini@redhat.com> References: <1566284395-30287-1-git-send-email-pbonzini@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Tue, 20 Aug 2019 07:01:12 +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] [PULL 32/36] HACKING: Document 'struct' keyword usage X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost 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" From: Eduardo Habkost Sometimes we use the 'struct' keyword in headers to help us reduce dependencies between header files. Document that practice. Signed-off-by: Paolo Bonzini Signed-off-by: Eduardo Habkost Signed-off-by: Paolo Bonzini --- HACKING | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/HACKING b/HACKING index 0fc3e0f..097d482 100644 --- a/HACKING +++ b/HACKING @@ -100,7 +100,19 @@ 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 are used to eliminate the redundant 'struct' keyword, since type +names have a different style than other identifiers ("CamelCase" versus +"snake_case"). Each named struct type should have a CamelCase name and a +corresponding typedef. + +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. However, as a matter +of convenience it is also perfectly fine to use forward struct +definitions instead of typedefs in headers and function prototypes; this +avoids problems with duplicated typedefs and reduces the need to include +headers from other headers. =20 2.4. Reserved namespaces in C and POSIX Underscore capital, double underscore, and underscore 't' suffixes should = be --=20 1.8.3.1