设为首页  
联系我们  
加入收藏  
网页制作 冲浪宝典 图形图像 操作系统 软件教学 编程开发 认证考试 安全技术 站长专区 文学驿站 娱乐天地 游戏天地 办公软件
文章搜索
您的位置: 首页 >> 文章首页 >> 编程开发 >> 其他开发语言 >> Apache DevelopersC Language Style Guide -- 最优代码风格(我认为)
精品推荐
其他开发语言点击TOP10
·数字小键盘指法练习
·用C语言编通讯录程序(初学者级别的)
·Modem 常用AT指令集
·单片机模拟I2C总线及24C02(I2C EEPROM)读写实例(源代码)
·C++经典电子书下载
·Thinking in C++ 简体中文第二版
·debug和release的区别
·error LNK2001: unresolved external symbol __ftol2 错误解决
·C库函数手册
·一个简单的C语言编译器
编程开发点击TOP10
·数字小键盘指法练习
·ASP.NET 程序中常用的三十三种代码
·用C语言编通讯录程序(初学者级别的)
·我写的Java学生成绩管理系统源代码
·CHK文件恢复工具
·Modem 常用AT指令集
·java笔试题
·异常java.sql.SQLException: Io exception:The Network Adapter could not establish connection
·单片机模拟I2C总线及24C02(I2C EEPROM)读写实例(源代码)
·C++经典电子书下载
精选专题

Apache DevelopersC Language Style Guide -- 最优代码风格(我认为)

作者: 来源:网络文章 时间:2005-12-17 21:00:48

Apache DevelopersC Language Style Guide -- 最优代码风格(我认为)(2) Each level of indentation of code is four spaces. Tab characters should never be used. Specific indentation rules for function declarations and control-flow keywords are given below.

Example:

 main(int argc, char **argc) {if (argc != 0) {fprintf(stderr, "No arguments allowed\n");exit(1);}exit(0); }

If an expression (or a routine declaration or invocation) would extend past column 80, the terms or arguments are wrapped at a convenient spot and the wrapped portion is indented under the first term in the expression (or the first argument to the function). Conditional expressions should be wrapped to keep single or parenthesized terms as atomic as possible, and place Boolean operators at either the start (preferable) or end of the line.

Example:

static const char *really_long_name(int i, int j,const char *args, void *foo,int k)if (cond1 && (item2  item3) && (!item4)&& (item5  item6) && item7) {do_a_thing();}
  • Comments

    Provide comments which explain the function of code where it is not clear from the code itself. Provide rationale where necessary for particular bits of code.

    Comments should be indented to same level as the surrounding text.

    Example:

     code; /* comment */ code;
  • Function Declaration and Layout

    Functions are laid out as follows:

     int main(int argc, char **argv) {code; }

    The return type is placed on the same line as the function. Arguments (if any) are given in ANSI style. If no arguments, declare function as void. No space between function name and opening bracket, single space after comma separating each argument. The opening brace is placed on the line after the definition, indented to line up with the start of the return type text. The code is indented with four spaces, and the closing brace is indented to line up with the opening brace. Also see the section on indenting long declarations and invocations.

  • 共3页 9 7 [1] [2] [38 :>

    Apache DevelopersC Language Style Guide -- 最优代码风格(我认为) 相关文章:
    Apache DevelopersC Language Style Guide -- 最优代码风格(我认为) 相关软件:
    特别声明:本站除部分特别声明禁止转载的专稿外的其他文章可以自由转载,但请务必注明出处和原始作者。文章版权归文章原始作者所有。对于被本站转载文章的个人和网站,我们表示深深的谢意。如果本站转载的文章有版权问题请联系编辑人员,我们尽快予以更正。
    转载请注明来源:http://www.xgdown.com