indenting #ifdef directives to level of surrounding code?#411
indenting #ifdef directives to level of surrounding code?#411mi-hol wants to merge 1 commit intoespotek-org:masterfrom
Conversation
|
@turboencabulator @mmehari I'd appreciate a quick feedback if these changes make the code better readable from your view. |
|
I would prefer to keep it the way it was since there are IDEs which grey out the not used code and it appears as if it was written without the directives. |
I'm not following, would you perhaps have a screenshot of what you tried to explain? |
@mmehari thanks, that triggers new questions.
|
Qt Creator 18.0.2
|
The screenshots leave me confused, because from my view the behaviour of QT Creator is the same for indented and non-indented directives. |
|
Yes, the behaviour is the same since QT Creator only greys out the code that will not be compiled. You didn't miss anything and I understand your point of view which at the end is a matter of preference. I am OK with your changes as well. |
From my view it's much more than personal preference because it "can reap significant improvements in comprehension and productivity". Reasoning is well explained in https://thelinuxcode.com/why-you-should-use-column-indentation-to-improve-your-codes-readability/ |
|
I think it is getting a bit out of context. For the record, I am in favor of indentation and I am not saying otherwise. But specific to this situation, pre-processor directives are resolved before compilation and people tend to do the indentation at this level. Which is why IDE editors grey them out and the reason for my preference. |
|
I'm with @mmehari on this one too. It seems strange to me to indent an #ifdef, since it doesn't compile to anything and isn't a part of the regular code. Preprocessor stuff starting at column 0 seems to be the style that Atmel use too: |
unfortunately not all IDEs have that feature. I understand now the reasoning behind your preferences much better and will close this PR, after updating the developer doc |
|
I wouldn't say Qt Creator specifically is the preferred IDE, on macOS/Linux especially I'd say Cursor or VS Code are easier to work with. |
|
superseeded by #437 |





also make conditional logic in preprocessor directives (i.e for PLATFORM_ definitions) better understandable by indenting them to level of surrounding code.
Note: no functional changes!