qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kurz <groug@kaod.org>
To: "Cédric Le Goater" <clg@kaod.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	Thomas Huth <thuth@redhat.com>,
	qemu-devel@nongnu.org, peter.maydell@linaro.org,
	Markus Armbruster <armbru@redhat.com>,
	Eric Blake <eblake@redhat.com>,
	"Dr. David Alan Gilbert" <dgilbert@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] HACKING: Clarify the paragraph about typedefs
Date: Fri, 11 Jan 2019 15:31:55 +0100	[thread overview]
Message-ID: <20190111153155.71e094ad@bahia.lan> (raw)
In-Reply-To: <694664dc-1bb7-0bb8-f44b-23b3175fea09@kaod.org>

On Fri, 11 Jan 2019 13:12:23 +0100
Cédric Le Goater <clg@kaod.org> wrote:

> On 1/11/19 11:38 AM, Paolo Bonzini wrote:
> > On 11/01/19 09:42, Thomas Huth wrote:  
> >>  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.
> >>    
> > 
> > I agree 100% with the wording after "Since".  However, I think the first
> > part should be made stronger, not weaker.
> > 
> > Typedefs are use to eliminate the redundant 'struct' keyword, since type
> > names have a different style than other identifiers ("CamelCase" versus
> > "snake_case").  Each struct 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 metter
> > 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.  
> 
> I suppose this is difficult to check with checkpatch ? It's easy to
> cross the border as I have proven many times. 

With Thomas's series merged, a simple build with clang will catch the
duplicated typedefs. Not sure it is worth the pain to teach checkpatch.

>  
> > And, I would move it to CODING_STYLE since we are at it. :)  
> 
> yes.
> 
> C.
> 

  reply	other threads:[~2019-01-11 14:32 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-11  8:42 [Qemu-devel] [PATCH] HACKING: Clarify the paragraph about typedefs Thomas Huth
2019-01-11 10:38 ` Paolo Bonzini
2019-01-11 12:12   ` Cédric Le Goater
2019-01-11 14:31     ` Greg Kurz [this message]
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=20190111153155.71e094ad@bahia.lan \
    --to=groug@kaod.org \
    --cc=armbru@redhat.com \
    --cc=clg@kaod.org \
    --cc=dgilbert@redhat.com \
    --cc=eblake@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=thuth@redhat.com \
    /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).