This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: soft-fp: Use parentheses around macro arguments


On Thu, 9 Oct 2014, Andreas Schwab wrote:

> "Joseph S. Myers" <joseph@codesourcery.com> writes:
> 
> > diff --git a/soft-fp/double.h b/soft-fp/double.h
> > index 1e6283e..36a11a5 100644
> > --- a/soft-fp/double.h
> > +++ b/soft-fp/double.h
> > @@ -90,21 +90,21 @@ union _FP_UNION_D
> >  };
> >  
> >  # define FP_DECL_D(X)		_FP_DECL (2, X)
> > -# define FP_UNPACK_RAW_D(X, val)	_FP_UNPACK_RAW_2 (D, X, val)
> > -# define FP_UNPACK_RAW_DP(X, val)	_FP_UNPACK_RAW_2_P (D, X, val)
> > -# define FP_PACK_RAW_D(val, X)	_FP_PACK_RAW_2 (D, val, X)
> > +# define FP_UNPACK_RAW_D(X, val)	_FP_UNPACK_RAW_2 (D, X, (val))
> > +# define FP_UNPACK_RAW_DP(X, val)	_FP_UNPACK_RAW_2_P (D, X, (val))
> > +# define FP_PACK_RAW_D(val, X)	_FP_PACK_RAW_2 (D, (val), X)
> 
> Why do you need that?  Unless you play tricks with a macro expanding to
> a comma it is impossible to put a literal comma in a macro argument
> without hiding it inside parens.

It's true that it's hard for a lack of parentheses to cause problems here 
- but it seems prudent just to follow a general rule that arguments (that 
are expressions) go in parentheses, to make it obvious to the reader that 
things are OK.  (In other places, soft-fp *does* use macro arguments that 
are macros expanding to contain commas, with a macro where such an 
argument is a single argument redirecting to one where it becomes multiple 
arguments.)

-- 
Joseph S. Myers
joseph@codesourcery.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]