Skip to content

Conversation

@tfliao
Copy link

@tfliao tfliao commented Mar 16, 2019

Unify coding style is good, but sometimes the style doesn't match the running style of editing file, or something else. It will be good if we allow programmer to use their judgement on this topic.

for example, I created an array of struct attribute for my attribute_group, but clang-format think all attributes should be declared in single line.

 static struct attribute *attrs[] = {                               
-    &result_attribute.attr,                                        
-    &reset_attribute.attr,                                         
+    &result_attribute.attr, &reset_attribute.attr,                 
     NULL, /* need to NULL terminate the list of attributes */      
 };                                                                 

@jserv
Copy link
Contributor

jserv commented Mar 16, 2019

For such special cases, it is simply best to instruct clang to not indent that block of code:

/* clang-format off */
...The Code...
/* clang-format on */

There is absolutely no way how you can teach an AST pretty printer to get that particular piece of code indented the way you want.

Never skip format check at first glance.

@jserv jserv closed this Mar 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants