简体   繁体   English

毫不犹豫地调整级联的“如果条件”

[英]Uncrustify to align cascaded “if conditions”

the combination of UniversalIndentGUI and Uncrustify works for me very fine and saves me lots of time to format the C source codes. UniversalIndentGUI和Uncrustify的结合对我来说非常有效,并且节省了我很多时间来格式化C源代码。 But I have a small extra question and want to know whether someone can help. 但是我还有一个小问题,想知道是否有人可以提供帮助。

Is it possible to correct the combined if conditions from: 如果满足以下条件,是否可以更正合并的内容:

if ( (a > 0) 
     && (b > 0) 
     && (c > 0))
{
...
}

to

if (     (a > 0) 
      && (b > 0) 
      && (c > 0)
    )
{
...
}

This may help the readability of the codes to some extend if more conditions are embedded together. 如果将更多条件嵌入在一起,则可以在一定程度上帮助提高代码的可读性。

Thanks 谢谢

I doubt there is a setting for that. 我怀疑这有一个设置。 It would be good idea for uncrustify to offer it. 毫无保留地提供它是一个好主意。

One not too good of a suggestion would be to define a macro or function: 一个不太好的建议是定义一个宏或函数:

#define ___(arg)  arg

and then you could have: 然后您可能会:

if ( ___( a > 0 )
     && ( b > 0 )
   )
{
}

but be aware the standard reserves macros that start with '_'. 但请注意以'_'开头的标准保留宏。 See: 看到:

What are the rules about using an underscore in a C++ identifier? 在C ++标识符中使用下划线的规则是什么?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM