I created this issue to centralize discussions about code style (solution and problems). I took some comments from the last PR :
I am not sure about the best way to handle that. Any proposals?
The problem is mixing preprocessor directives indenting with statements (if, for, switch, ...) indenting that might yield very misleading looking code when preprocessor is heavy used with code.
example:
void foo(void) {
#if TEST1 == 0
#if TEST2 == 0
if (true) { // This if is on the wrong indentation
#endif
#endif
for (int i = 0; i < 10; ++i) {
// do something
}
#if TEST1 == 0
#if TEST2 == 0
} // This brace is on the wrong indentation
#endif
#endif
}
I think we can reverse the logic, set IndentPPDirectives: None and add manual indentation when it is pertinent with clang-format off.
Edit: It might be worth it. Most styles do not indent directives.
Edit: Maybe reordering the code that way, that only one code segment needs to be excluded from auto formatting.
I think you shouldn't code based on formatter (most of the time). We add unnecessary complexity when programming
@rokath
Maybe we keep the trice8|16|32|64.c|h files inside .clang-format-ignore. These files would loose readability for my taste when re-formatted with IndentPPDirectives: None. But I have no strong opinion on this because they then formatted differently to trice.c|h. On trice.c|h I agree to drop the pre-processor macros indent.
Edit: https://stackoverflow.com/questions/2975330/how-do-you-indent-preprocessor-statements
I created this issue to centralize discussions about code style (solution and problems). I took some comments from the last PR :
The problem is mixing preprocessor directives indenting with statements (if, for, switch, ...) indenting that might yield very misleading looking code when preprocessor is heavy used with code.
example:
I think we can reverse the logic, set
IndentPPDirectives: Noneand add manual indentation when it is pertinent withclang-format off.Edit: It might be worth it. Most styles do not indent directives.
I think you shouldn't code based on formatter (most of the time). We add unnecessary complexity when programming