Re: [PATCH] gettext: more-consistent no-op macros

Bruno Haible via Gnulib discussion list <[email protected]>
Newsgroups gmane.comp.lib.gnulib.bugs
Message-ID <5615335.zI817sQ0lx@cagnes>
Paul Eggert wrote:
>  # elif defined __clang__
>  #  undef gettext
> -#  define gettext(Msgid) ((const char *) (Msgid))
> +#  define gettext(Msgid) ((const char *) {(Msgid)})
>  #  undef dgettext
> -#  define dgettext(Domainname, Msgid) gettext (Msgid)
> +#  define dgettext(Domainname, Msgid) \
> +     ((void) (const char *) {(Domainname)}, gettext (Msgid))
>  #  undef dcgettext
> -#  define dcgettext(Domainname, Msgid, Category) dgettext (Domainname, Msgid)
> +#  define dcgettext(Domainname, Msgid, Category) \
> +     ((void) (int) {(Category)}, dgettext (Domainname, Msgid))

clang in C++ mode accepts the compound initializer syntax
  (TYPE) { VALUE... }
but — unlike gcc in C++ mode — requires that the values be constant
expressions.

As far as I can see, your patch will have the effect that
  gettext (some_function_that_returns_a_string ())
will produce a syntax error in C++ mode.

Am I correct?

Bruno
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.