-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix indentation #48
Comments
I've tried clang-format on the code base and it works, the trick is to set See this gist for c_init.c in different clang-format styles: |
I won't try to defend any aspect of my terrible code formatting. Anything that makes it less terrible sounds good. |
I would be happy to go through and clean up the indentation of files, but would like to ask if you prefer tabs or spaces @linleyh? |
Great! |
I am unsure what others use (other than @melvinzhang suggested clang style), but I try to follow the Linux kernel development coding style. They use 8 character indentation, which they state "Rationale: The whole idea behind indentation is to clearly define where a block of control starts and ends. Especially when you’ve been looking at your screen for 20 straight hours, you’ll find it a lot easier to see how the indentation works if you have large indentations." Would like to get thoughts though. |
If that's how the Linux kernel is indented, it's probably the way to go. |
https://github.com/torvalds/linux/blob/master/.clang-format can be used to produce linux kernel style using clang-format. Unfortunately, clang-format is missing support for alignment of defines and initializers, see https://www.kernel.org/doc/html/latest/process/clang-format.html#missing-support |
That should be okay - the code doesn't really have enough defines for that to be a problem, and I don't think it has any designated initialisers. |
Indentation is completely broken right now. There's a weird mix of tabs and spaces, indentation depths differs, … It's bad enough that gcc is confused and (wrongly) complains about unguarded statements all over the place:
It's also really hard to read…
Could you fix this?
Alternatively, I could try to set up and run a code formatter on this and make a pull request – in which case, what should the indentation be?
grep|sed|sort|uniq
chain. (For me, single-space indentation is hard to read – with spaces, I'd suggest at least two per indentation level.)The text was updated successfully, but these errors were encountered: