If statement 使用Uncrustify为If-else添加大括号

If statement 使用Uncrustify为If-else添加大括号,if-statement,uncrustify,If Statement,Uncrustify,我想知道是否有任何方法可以使用Uncrustify在嵌套if-else中添加大括号。例如: if( stat_error == -1 ){ if ( debug > 0 ) printf( "...ERROR ); //I would like to add braces around here. exit( -1 ); } else { 我看到了这一点: # Add or remove braces on single-line 'if' statement.

我想知道是否有任何方法可以使用Uncrustify在嵌套if-else中添加大括号。例如:

if( stat_error == -1 ){
   if ( debug > 0 )
      printf( "...ERROR ); //I would like to add braces around here.
   exit( -1 );
} else {
我看到了这一点:

# Add or remove braces on single-line 'if' statement. Will not remove the braces if they contain an 'else'.
mod_full_brace_if                        = add   # ignore/add/remove/force
但它似乎不适用于嵌套条件句


有什么办法吗?

您需要添加一个return语句,它应该是这样的

    if( stat_error == -1 ){
   if ( debug > 0 )
      printf( "...ERROR ); //I would like to add braces around here.
   exit( -1 );
} else{

Insert else statement
}
return statement here
}

在你的例子中,我对Uncrustify的体验是:

在单行
if
语句中添加或删除大括号。如果大括号包含
else
,则不会删除大括号

使链中的所有
if
/
elseif
/
else
语句是否用括号括起来。覆盖
mod\u full\u brake\u如果

如果任何一个必须支撑,它们都是支撑的。如果所有支架都可以无支撑,则会移除支架


这对我很有效。

我不明白。我为什么要补充这一点?这个答案与所问的问题毫无关系。
mod_full_brace_if = add
mod_full_brace_if_chain = false