You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Julian Foad <ju...@btopenworld.com> on 2008/11/11 19:57:32 UTC

Re: svn commit: r34145 - in trunk: . subversion www

On Tue, 2008-11-11 at 11:39 -0800, arfrever@tigris.org wrote:
>   (Q_): Add parenthesis around definition for consistency with definitions
>    of other macros.

> -#define Q_(x1, x2, n) (n == 1) ? x1 : x2
> +#define Q_(x1, x2, n) ((n == 1) ? x1 : x2)

You should parenthesize each argument as well as the whole expression:

  (((n) == 1) ? (x1) : (x2))

Otherwise invocations such as

  Q_(item[0].is_dir ? "file" : "directory",
     "items",
     number_of_items)

would go wrong.

Thanks.
- Julian



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: svn commit: r34145 - in trunk: . subversion www

Posted by Arfrever Frehtes Taifersar Arahesis <ar...@gmail.com>.
2008-11-11 20:57 Julian Foad <ju...@btopenworld.com> napisaƂ(a):
> On Tue, 2008-11-11 at 11:39 -0800, arfrever@tigris.org wrote:
>>   (Q_): Add parenthesis around definition for consistency with definitions
>>    of other macros.
>
>> -#define Q_(x1, x2, n) (n == 1) ? x1 : x2
>> +#define Q_(x1, x2, n) ((n == 1) ? x1 : x2)
>
> You should parenthesize each argument as well as the whole expression:
>
>  (((n) == 1) ? (x1) : (x2))
>
> Otherwise invocations such as
>
>  Q_(item[0].is_dir ? "file" : "directory",
>     "items",
>     number_of_items)
>
> would go wrong.

xgettext doesn't support this syntax, so it's better to cause
compilation failure than untranslated message.