[lkml]   [2004]   [Feb]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRe: PATCH, RFC: Version 3 of 2.6 Codingstyle
    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
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to
    More majordomo info at
    Please read the FAQ at

     \ /
      Last update: 2005-03-22 14:00    [W:0.020 / U:30.596 seconds]
    ©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site