[clang] [clang-format] Add SpaceBeforeUnderscoreParens option for GNU gettext… (PR #159925)

via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 22 02:24:15 PDT 2025


klausgerlicher wrote:

> > > In general, we want the new option to meet the [requirements](https://clang.llvm.org/docs/ClangFormatStyleOptions.html#adding-additional-style-options). Can you link to the relevant section in GNU coding standards? It seems that this can be supported without a new option.
> > 
> > 
> > Hi @owenca thanks for providing feedback so quickly.
> > So in general I read from this that in GNU style mode, this could generally avoid separating "_(" and we wouldn not need an option. Could you please explain though what you mean with meet the requirements here? I haven't had any exposure to LLVM policies, just trying to fix some behaviour which was seen over a few years.
> 
> If click the link, you will see the requirements at the end of the section.

I read up on this a bit:

I could not find a good indication of this in the GNU coding docs.

However in the gettext() documentation the underscore macro is described.  https://www.gnu.org/software/gettext/manual/html_node/Mark-Keywords.html

`Many packages use ‘_’ (a simple underline) as a keyword, and write ‘_("Translatable string")’ instead of ‘gettext ("Translatable string")’. Further, the coding rule, from GNU standards, wanting that there is a space between the keyword and the opening parenthesis is relaxed, in practice, for this particular usage. So, the textual overhead per translatable string is reduced to only three characters: the underline and the two parentheses. However, even if GNU gettext uses this convention internally, it does not offer it officially. The real, genuine keyword is truly ‘gettext’ indeed. It is fairly easy for those wanting to use ‘_’ instead of ‘gettext’ to declare:`

So this would indicate that in GNU style we could do this w/o adding an option.


https://github.com/llvm/llvm-project/pull/159925


More information about the cfe-commits mailing list