← Back to team overview

kicad-developers team mailing list archive

Re: [PATCH] Add clang-format configuration

 

I'm OK with this.  If clang handles indenting the _() macro properly,
that is definitely an improvement over uncrustify.

On 3/13/2017 9:42 AM, Chris Pavlina wrote:
> Hi,
> 
> Currently, our preferred code formatting tool is Uncrustify. Uncrustify
> is bad. It does things like this:
> 
> wxString m_choiceAntialiasingChoices[] =
>         {
>             _( "No Antialiasing" ),
>             _( "Subpixel Antialiasing (High Quality)" ),      _(
>                     "Subpixel Antialiasing (Ultra Quality)" ),_( "Supersampling (2x)" ), _(
>                     "Supersampling (4x)" )
>         };
> 
> Yes, that's an actual Uncrustify output with our configuration, posted
> on IRC this morning.
> 
> Per metacollin's suggestion I looked into clang-format, which does a
> MUCH nicer job because it uses clang's parser to actually understand the
> code it's formatting. I wrote up a clang-format config following the
> KiCad coding style. Here is the output of clang-format on the same code:
> 
> wxString m_choiceAntialiasingChoices[] = { _( "No Antialiasing" ),
>     _( "Subpixel Antialiasing (High Quality)" ),
>     _( "Subpixel Antialiasing (Ultra Quality)" ),
>     _( "Supersampling (2x)" ),
>     _( "Supersampling (4x)" ) };
> 
> It's not perfect, but it's way better than Uncrustify.
> 
> The attached patch adds a _clang-format configuration file to the root
> of the repository.
> 
> 
> 
> _______________________________________________
> Mailing list: https://launchpad.net/~kicad-developers
> Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~kicad-developers
> More help   : https://help.launchpad.net/ListHelp
> 


Follow ups

References