-
C and C++ Style Guides
2008-05-31
版权声明:转载时请以超链接形式标明文章原始出处和作者信息及本声明
http://cbkid.blogbus.com/logs/21984813.html
http://www.chris-lott.org/resources/cstyle/
Linus Torvalds:
1.制表符8位。
2.大括号:
if (x is true) {
we do y
}int function(int x)
{
body of function
}
do {
body of do-loop
} while (condition);if (x == y) {
..
} else if (x > y) {
...
} else {
....
}
3.变量名:全局要用有意义的(count_active_users()" or similar, you should _not_ call it "cntusr()".
局部变量要简短比如(i,tmp)
4 .函数:
函数应该简短干练。且局部变量应该少于十个。
5.注释:Generally, you want your comments to tell WHAT your code does, not HOW.
Also, try to avoid putting comments inside a function body ,
put the comments at the head
of the function, telling people what it does, and possibly WHY it does
it.。。。
随机文章:
在 Vim 上使用 Slippery Snippet ( Textmate-Like ) 2008-06-06bop系列 2009-03-13使用gvim作python的编辑器 2009-03-08献给在机房上网的朋友们 2008-10-07李纳斯大神的十句名言 2008-06-09
收藏到:Del.icio.us







