All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Robert P. J. Day" <rpjday@crashcourse.ca>
To: Joe Perches <joe@perches.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] Documentation/CodingStyle: Mention multi-line macros using expressions
Date: Fri, 13 Jul 2012 08:43:51 -0400 (EDT)	[thread overview]
Message-ID: <alpine.DEB.2.02.1207130842530.27681@oneiric> (raw)
In-Reply-To: <1342030482.22278.8.camel@joe2Laptop>

On Wed, 11 Jul 2012, Joe Perches wrote:

> On Wed, 2012-07-11 at 13:32 -0400, Robert P. J. Day wrote:
> []
> > diff --git a/Documentation/CodingStyle b/Documentation/CodingStyle
> []
> > +A newer technique is to use the GCC extension of being able to place
> > +statements and declarations in an expression, as with this example from
> > +the <linux/kernel.h> header file:
> > +
> > +#define roundup(x, y) (				\
> > +{						\
> > +        const typeof(y) __y = y;		\
> > +        (((x) + (__y - 1)) / __y) * __y;	\
> > +}						\
> > +)
>
> Hi Robert.
>
> How about the phrase "GCC's statement expression extension"
> or maybe give a link like:
> http://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html

  ok, i'll do that later today.

> Please put the opening ({ and closing )} on a single line.
> It's shorter and makes grep easier.
>
> #define statement_expression(args)		\
> ({						\
> 	etc					\
> })

  i was simply transcribing what was in kernel.h verbatim, but i'll
tuck it together for brevity.

rday

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================

      reply	other threads:[~2012-07-13 12:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-11 17:32 [PATCH] Documentation/CodingStyle: Mention multi-line macros using expressions Robert P. J. Day
2012-07-11 18:14 ` Joe Perches
2012-07-13 12:43   ` Robert P. J. Day [this message]

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=alpine.DEB.2.02.1207130842530.27681@oneiric \
    --to=rpjday@crashcourse.ca \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.