How can I align function parameter names in clang-format?

后端 未结 3 2058
渐次进展
渐次进展 2021-01-13 20:36

Is it possible to use clang-format to format struct members and function parameter names into columns?

For example:

struct
{
   int                


        
3条回答
  •  忘掉有多难
    2021-01-13 21:03

    Following up on your post, I'm able to get the following:

    struct
    {
      int          alpha;
      unsigned int beta;
      MyObject *   gamma;
    };
    
    void foobar( int          alphaXXXXXXXXXX,
                 unsigned int betaXXXXXXXXX,
                 MyObject *   gammaXXXXXXXX )
    {
    }
    

    with BinPackArguments and BinPackParameters both false, and AlignConsecutiveAssignments and AlignConsecutiveDeclarations both set to true (documentation of these parameters). I had to extend the length of the variables to the function, because the original could fit all of them on one line.

提交回复
热议问题