In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article will explain in detail what the linux kernel code style is, and the content of the article is of high quality, so the editor will share it for you as a reference. I hope you will have some understanding of the relevant knowledge after reading this article.
Code style, like human taste and self-cultivation, to a certain extent reflects the attitude of programmers to do things.
Common code styles include Linux kernel code style and companies' own defined code style. Here is a brief description of the kernel code style:
1. Indentation and whitespace
(1) add a space separation between if, while, for and the closing parenthesis, and the expression within the parenthesis is close to the parenthesis
While (a = = 3)
(2) the character terminal of the UNIX system standard is 24 lines and 80 columns, so if the character is long, you should fold the line and align the line with the above expression with a space, for example
If (sqrt (x + y) > 5. 0 & & x
< 0.0 && y >0.0)
(3) alignment of parentheses, such as if / else, while, do/while, for, switch
If (...) {} else if (...) {...} switch () {case'Aids:.... case'Bones:.... default:....}
two。 Annotation
Put it on top of the function for a long time, close to no space
/ * * name: function_test * function: to test * / void function_test () {.... }
Shorter can be placed on the right side of the same line.
Int num; / * to count the num * /
3. Identifier naming
(1) commonly used abbreviations
Count-> cnt
Block-> blk
Length-> len
Window-> win
Message-> msg
Temporary-> tmp
Internationalization-> i18n
Tans-> x
Transmit-> xmit
Use capital case for constant constant QUEUE_LEN
Variables are lowercase + underscore example variable radix_tree_insert
Similar identifier styles are Microsoft's Hungarian nomenclature. Kernel style is recommended here, get into the habit and keep the same.
4. Indent
You can convert the code to a certain style with the help of the tool indent, and here you will
Here the code is converted to kernel code style:
Indent-kr-i4 main.c is fine.
The-kr option indicates the use of krypr style, and-i4 indicates indentation of four spaces. But indent can't automatically add blank lines to the code, so you need to form your own habits.
On how the linux kernel code style is shared here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.