public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jamie Lokier <jamie@shareable.org>
To: Dmitry Torokhov <dtor_core@ameritech.net>
Cc: linux-kernel@vger.kernel.org, Michael Frank <mhf@linuxmail.org>
Subject: Re: PATCH, RFC: Version 3 of 2.6 Codingstyle
Date: Sun, 15 Feb 2004 10:09:27 +0000	[thread overview]
Message-ID: <20040215100927.GA10781@mail.shareable.org> (raw)
In-Reply-To: <200402132244.04843.dtor_core@ameritech.net>

Dmitry Torokhov wrote:
> On Friday 13 February 2004 08:44 pm, Michael Frank wrote:
> > -expression in parenthesis. Note that this does not eliminate all side effects.
> > +4) forgetting about side effects: macros defining expressions must enclose each
> > +parameter and the expression in parentheses.
> >  
> >  #define CONSTEXP (CONSTANT | 3)
> >  #define MACWEXP(a,b) ((a) + (b))
> >
> 
> The statements above are incorrect.
> 
> Parentheses will never eliminate a side effect, macros do not have a
> "side effect problem". Functions and macros both can have side effects
> and sometimes side effect is a desired outcome.

Macros do have a side effect problem, but it is not something which is
fixed by parentheses.  The problem comes when the argument of the
macro is repeated more than once, or zero times, in the macro body.
Then any side effect that the caller was expecting takes place the
wrong number of times.

A subtler version occurs when the caller expects the side effect in an
argument to occur before the action of the macro, but the macro
doesn't expand the argument in that order.

See "Duplication of Side Effects" in the GNU CPP manual.

-- Jamie

  reply	other threads:[~2004-02-15 10:09 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-12 22:15 PATCH, RFC: 2.6 Documentation/Codingstyle Michael Frank
2004-02-12 23:20 ` Tim Bird
2004-02-12 23:46   ` Måns Rullgård
2004-02-13  0:19   ` Tim Hockin
2004-02-12 23:38 ` Randy.Dunlap
2004-02-13  1:50   ` Alex Goddard
2004-02-13  1:52   ` Maciej Zenczykowski
2004-02-13  0:13 ` viro
2004-02-13  1:12 ` J. Bruce Fields
2004-02-13  8:49 ` PATCH, RFC: Version 2 of 2.6 Codingstyle Michael Frank
2004-02-13  9:44   ` Andries Brouwer
2004-02-13 11:24     ` Nikita Danilov
2004-02-16 17:56     ` Ludootje
2004-02-13 22:38   ` Randy.Dunlap
2004-02-13  8:58 ` PATCH, RFC: 2.6 Documentation/Codingstyle Giuliano Pochini
2004-02-13  9:10   ` Andrew Morton
2004-02-13  9:49     ` Michael Frank
2004-02-13 10:09       ` Nick Piggin
2004-02-13 10:50         ` Michael Frank
2004-02-18  7:39           ` Miles Bader
2004-02-13 12:44     ` viro
2004-02-13  9:19   ` David Weinehall
2004-02-13 11:42   ` Andries Brouwer
2004-02-13 12:13     ` Måns Rullgård
2004-02-13 12:42     ` Ed Tomlinson
2004-02-13 13:55     ` Giuliano Pochini
2004-02-13 14:35       ` Angelo Dell'Aera
2004-02-13 15:42         ` Giuliano Pochini
2004-02-13 15:48         ` Valdis.Kletnieks
2004-02-13 16:38           ` Angelo Dell'Aera
2004-02-13 17:03             ` Valdis.Kletnieks
2004-02-13 16:18       ` viro
2004-02-14  0:38 ` Kevin O'Connor
2004-02-14  0:56   ` Valdis.Kletnieks
2004-02-14  1:44 ` PATCH, RFC: Version 3 of 2.6 Codingstyle Michael Frank
2004-02-14  3:44   ` Dmitry Torokhov
2004-02-15 10:09     ` Jamie Lokier [this message]
2004-02-14 20:44 ` PATCH, RFC: Version 4 " Michael Frank
2004-02-14 21:27   ` viro
2004-02-16  3:47 ` PATCH, RFC: Version 5 " Michael Frank

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=20040215100927.GA10781@mail.shareable.org \
    --to=jamie@shareable.org \
    --cc=dtor_core@ameritech.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhf@linuxmail.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