浏览代码

documentation/coding_style_cn.txt: indent the code

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1826 bbd45198-f89e-11dd-88c7-29a3b14d5316
chaos.proton@gmail.com 13 年之前
父节点
当前提交
75b78f85e4
共有 1 个文件被更改,包括 38 次插入38 次删除
  1. 38 38
      documentation/coding_style_cn.txt

+ 38 - 38
documentation/coding_style_cn.txt

@@ -91,7 +91,7 @@ C语言头文件为了避免多次重复包含,需要定义一个符号。这
 接口,必须在相应的头文件中声明;如果函数入口参数是空,必须使用 void 作为入口参
 数,例如:
 
-rt_thread_t rt_thread_self(void);
+	rt_thread_t rt_thread_self(void);
 
 
 8.注释编写
@@ -110,19 +110,19 @@ rt_thread_t rt_thread_self(void);
 缩进请采用 TAB 字符或 4 个空格的方式进行,推荐使用4个空格的方式进行缩进。如果没
 有什么特殊意义,请在 "{" 的下一行都采用缩进的方式,例如:
 
-if (condition) 
-{
-    /* others */
-}
+	if (condition) 
+	{
+		/* others */
+	}
 
 唯一的例外是 swtich 语句,switch-case 语句采用 case 语句与 swtich 对齐的方式,
 例如:
 
-switch (value)
-{
-case value1:
-    break;
-}
+	switch (value)
+	{
+	case value1:
+		break;
+	}
 
 case 语句与前面的 switch 语句对齐,后续的语句则采用缩进的方式。
 
@@ -131,33 +131,33 @@ case 语句与前面的 switch 语句对齐,后续的语句则采用缩进的
 
 从代码阅读角度,建议每个大括号单独占用一行,而不是跟在语句的后面,例如:
 
-if (condition)
-{
-	/* others */
-}
+	if (condition)
+	{
+		/* others */
+	}
 
 匹配的大括号单独占用一行,代码阅读起来就会有相应的层次而不会容易出现混淆的情况
 
 空格建议在非函数方式的括号调用前留一个空格以和前面的进行区分,例如:
 
-if (x <= y)
-{
-    /* others */
-}
+	if (x <= y)
+	{
+		/* others */
+	}
 
-for (index = 0; index < MAX_NUMBER; index ++)
-{
-    /* others */
-}
+	for (index = 0; index < MAX_NUMBER; index ++)
+	{
+		/* others */
+	}
 
 建议在括号前留出一个空格(涉及的包括if、for、while、swtich语句),而运算表达式
 中,运算符与字符串间留一个空格。另外,不要在括号的表达式两侧留空格,例如:
 
-if ( x <= y )
-{
-    /* other */
-}
+	if ( x <= y )
+	{
+		/* other */
+	}
 
 这样括号内两侧的空格是不允许的。
 
@@ -187,21 +187,21 @@ if ( x <= y )
 RT-Thread 内核采用了 C 语言对象化技术,命名表现形式是:对象名结构体表示类定义、
 对象名 + 动词短语形式表示类方法,例如:
 
-struct rt_timer
-{
-	struct rt_object parent;
-    /* other fields */
-};
-typedef struct rt_timer* rt_timer_t;
+	struct rt_timer
+	{
+		struct rt_object parent;
+		/* other fields */
+	};
+	typedef struct rt_timer* rt_timer_t;
 
 结构体定义rt_timer代表了timer对象的类定义;
 
-rt_timer_t rt_timer_create(const char* name,
-	void (*timeout)(void* parameter), void* parameter,
-	rt_tick_t time, rt_uint8_t flag);
-rt_err_t rt_timer_delete(rt_timer_t timer);
-rt_err_t rt_timer_start(rt_timer_t timer);
-rt_err_t rt_timer_stop(rt_timer_t timer);
+	rt_timer_t rt_timer_create(const char* name,
+		void (*timeout)(void* parameter), void* parameter,
+		rt_tick_t time, rt_uint8_t flag);
+	rt_err_t rt_timer_delete(rt_timer_t timer);
+	rt_err_t rt_timer_start(rt_timer_t timer);
+	rt_err_t rt_timer_stop(rt_timer_t timer);
 
 rt_timer + 动词短语的形式表示能够应用于 timer 对象的方法。