Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Indentation style
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Linux kernel === The [[Linux kernel]] source tree is styled in a variant of K&R.<ref>A detailed description of the style is given at [https://www.kernel.org/doc/html/latest/process/coding-style.html kernel.org].</ref> [[Linus Torvalds]] advises contributors to follow it. Attributes include: * Uses [[tab character]]s for indentation (not spaces) and assumes [[tab stop]]s every 8 spaces * Brace layout matches K&R, with the braces of function definitions on their own lines and the opening brace of compound statements on the same line as the control clause, separated by a space * Labels in a <code>switch</code> statement are aligned with the enclosing block (there is only one level of indents) * Maximum line length is 100 characters although the pre-2020 limit of 80 characters is preferred.<ref>{{cite web |last1=Larabel |first1=Michael |title=The Linux Kernel Deprecates The 80 Character Line Coding Style |url=https://www.phoronix.com/scan.php?page=news_item&px=Linux-Kernel-Deprecates-80-Col |website=Phoronix |publisher=Phoronix Media |access-date=1 May 2022}}</ref> * A single-statement body of a compound statement (such as if, while, and do-while) does not need to be surrounded by curly braces. If, however, one or more of the substatements in an <code>if-else</code> statement require braces, then both substatements should be wrapped in braces: <syntaxhighlight lang=c> int power(int x, int y) { int result; if (y < 0) { result = 0; } else { result = 1; while (y-- > 0) result *= x; } return result; } </syntaxhighlight>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)