qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, peter.maydell@linaro.org,
	"Markus Armbruster" <armbru@redhat.com>,
	"Cédric Le Goater" <clg@kaod.org>, "Greg Kurz" <groug@kaod.org>,
	"Eric Blake" <eblake@redhat.com>,
	"Dr. David Alan Gilbert" <dgilbert@redhat.com>
Subject: [Qemu-devel] [PATCH] HACKING: Clarify the paragraph about typedefs
Date: Fri, 11 Jan 2019 09:42:28 +0100	[thread overview]
Message-ID: <1547196148-12250-1-git-send-email-thuth@redhat.com> (raw)

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 <thuth@redhat.com>
---
 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 the storage
 it points to, or it is aliased to another pointer that is.
 
 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.
 
 2.4. Reserved namespaces in C and POSIX
 Underscore capital, double underscore, and underscore 't' suffixes should be
-- 
1.8.3.1

             reply	other threads:[~2019-01-11  8:42 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-11  8:42 Thomas Huth [this message]
2019-01-11 10:38 ` [Qemu-devel] [PATCH] HACKING: Clarify the paragraph about typedefs Paolo Bonzini
2019-01-11 12:12   ` Cédric Le Goater
2019-01-11 14:31     ` Greg Kurz
2019-01-16 10:58   ` [Qemu-devel] HACKING vs. CODING_STYLE (was: Re: [PATCH] HACKING: Clarify the paragraph about typedefs) Thomas Huth
2019-01-16 11:22     ` Paolo Bonzini
2019-01-16 14:43     ` Eric Blake

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1547196148-12250-1-git-send-email-thuth@redhat.com \
    --to=thuth@redhat.com \
    --cc=armbru@redhat.com \
    --cc=clg@kaod.org \
    --cc=dgilbert@redhat.com \
    --cc=eblake@redhat.com \
    --cc=groug@kaod.org \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).