Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Yao Qi <qiyaoltc@gmail.com>
Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: Re: [PATCH] gdb: Use vector::emplace_back
Date: Wed, 09 Nov 2016 12:21:00 -0000	[thread overview]
Message-ID: <1257b752-107c-684f-feb9-5b190b1575b8@redhat.com> (raw)
In-Reply-To: <CAH=s-PN18zXqL7RYRfQiX=0Sg-0kYtZ-LyLDYz4O4_+jNpE=mw@mail.gmail.com>

On 11/09/2016 11:12 AM, Yao Qi wrote:
> Hi Pedro,
> Patch is good to me, a question on coding style below,
> 
> On Wed, Nov 9, 2016 at 12:39 AM, Pedro Alves <palves@redhat.com> wrote:
>>  /* Arguments of --command option and its counterpart.  */
>> -struct cmdarg {
>> +struct cmdarg
>> +{
>> +  cmdarg (cmdarg_kind type_, char *string_)
>> +    : type (type_), string (string_)
>> +  {}
>> +
> 
> Is there any reason you name parameters with tailing "_"?  I don't
> see anything about tailing "_" in  GDB or GCC C++ code standard.

We just need names for the parameters that are obviously similar
to the public members of the struct they'll be assigned to
in the member initializer list just below.  (We use "m_" prefix for
private members.  Public members of plain old data structs don't get
the "m_" prefix.)

Leading or trailing underscore are the most obvious choices, I think.

I mildly prefer trailing over leading for being less easily confused
with "m_" IMO, and also, some coding conventions use single leading
underscore for private member.  I see gcc using trailing underscore
for "shadow" parameters too.  E.g.:

id_base::id_base (id_kind kind_, const char *id_, int nargs_)
{
  kind = kind_;
  id = id_;
  nargs = nargs_;
  hashval = htab_hash_string (id);
}

But it's probably possible to find different examples if you
look deep enough.

Would you do/prefer something different?

Thanks,
Pedro Alves


  reply	other threads:[~2016-11-09 12:21 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-09  0:39 Pedro Alves
2016-11-09 11:12 ` Yao Qi
2016-11-09 12:21   ` Pedro Alves [this message]
2016-11-09 12:43     ` Yao Qi
2016-11-09 12:55       ` Pedro Alves
2016-11-09 14:50         ` John Baldwin
2016-11-09 15:27           ` Pedro Alves
2016-11-09 17:08             ` John Baldwin
2016-11-09 18:45               ` Pedro Alves

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=1257b752-107c-684f-feb9-5b190b1575b8@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=qiyaoltc@gmail.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