2-5 Linux编程规范
2016-09-09 09:34
134 查看
(近来用得比较多的规范框架在这里)
1. 文件头,如
/**************************************
* 文件名: addr.c *
* 创建者: xyz *
* 创建时间:20150606 *
* 程序说明:打印变量地址 *
**************************************/
2. 函数头,如
/**************************************
* 函数名: add *
* 参数: int a, int b *
* 输入: int a, int b *
* 返回: int c *
* 函数功能: 执行加法运算 *
**************************************/
3. 一些该注意的地方:
3.1 加注释时,应使用/* ............. */ ,而尽量避免使用 //.........
3.2 注意缩进,使用4个空格,而避免直接使用tab键
3.3 括号必须对齐(当然,不对齐的话,编辑器一般会有提示)
4. 最近比较常用的注释框架:
4.1 HeadFileDescription
/**************************************************************************************************
* Header File
*
* File Name : FN_FileName.c/ FN_FileName.h
* Copyright : 2016 ~ 2020 Elvin Corporation, All rights Reserved.
* Module Name : Display
*
* CPU : X86
* RTOS : windows7 32bit
*
* Create Date : 2016/04/21
* Author/Corporation : Elvin/ESYS Company
*
* Abstract Description : some function about seqlist.
*
*------------------------Revision History------------------------------------------------
* No Version Date Revised By Item Description
* 1 0.02 2016/04/21 Elvin Seqlist Just a test
**************************************************************************************************/
/**************************************************************************************************
* Muti-Include-Prevent Section
**************************************************************************************************/
#ifndef _FN_FILENAME_H
#define _FN_FILENAME_H
/**************************************************************************************************
* Debug switch Section
**************************************************************************************************/
#define D_FILENAME_BASE
/**************************************************************************************************
* Include File Section
**************************************************************************************************/
/* Perhaps there are some file will be Included */
/* No file will be Included */
#include "IncFile.h"
/**************************************************************************************************
* Macro Define Section
**************************************************************************************************/
/* Perhaps there are some Macro will be defined */
/* No Macro will be defined */
#define MAX_TIMER_OUT
/**************************************************************************************************
* Struct Define Section
**************************************************************************************************/
/* Perhaps there are some Struct be defined */
/* No Struct will be defined */
typedef struct Seqlist
{
int capacity;
int length;
}Seqlist_st, * Seqlist_pst;
/**************************************************************************************************
* Protoryppe Declare Section
**************************************************************************************************/
Seqlist_pst SeqlistCreate(int capacity);
#endif
4.2 SourceFileDescription
/**************************************************************************************************
* Source File
*
* File Name : FN_FileName.c
* Copyright : 2016 ~ 2020 Elvin Corporation, All rights Reserved.
* Module Name : Display
*
* CPU : X86
* RTOS : windows7 32bit
*
* Create Date : 2016/04/21
* Author/Corporation : Elvin/ESYS Company
*
* Abstract Description : some function about seqlist.
*
*------------------------Revision History------------------------------------------------
* No Version Date Revised By Item Description
* 1 0.02 2016/04/21 Elvin Seqlist Just a test
**************************************************************************************************/
/**************************************************************************************************
* Debug switch Section
**************************************************************************************************/
#define D_FILENAME_BASE
/**************************************************************************************************
* Include File Section
**************************************************************************************************/
/* Perhaps there are some file will be Included */
/* No file will be Included */
#include "IncFile.h"
/**************************************************************************************************
* Macro Define Section
**************************************************************************************************/
/* Perhaps there are some Macro will be defined */
/* No Macro will be defined */
#define MAX_TIMER_OUT
/**************************************************************************************************
* Struct Define Section
**************************************************************************************************/
/* Perhaps there are some Struct be defined */
/* No Struct will be defined */
typedef struct Seqlist
{
int capacity;
int length;
}Seqlist_st, * Seqlist_pst;
/**************************************************************************************************
* Prototype Declare Section
**************************************************************************************************/
Seqlist_pst SeqlistCreate(int capacity);
/**************************************************************************************************
* Global Variable Declare Section
**************************************************************************************************/
/* Perhaps there are some Global Variable be defined */
/* No Global Variable will be defined */
extern unsigned int SeqlistNode;
/**************************************************************************************************
* File Static Variable Declare Section
**************************************************************************************************/
/*
4000
Perhaps there are some Static Variable be defined */
/* No Static Variable will be defined */
static unsigned int SeqlistStatus;
/**************************************************************************************************
* Function Declare Section
**************************************************************************************************/
Seqlist_pst SeqlistCreate(int capacity)
{
Seqlist_pst slist = NULL;
return slist;
}
1. 文件头,如
/**************************************
* 文件名: addr.c *
* 创建者: xyz *
* 创建时间:20150606 *
* 程序说明:打印变量地址 *
**************************************/
2. 函数头,如
/**************************************
* 函数名: add *
* 参数: int a, int b *
* 输入: int a, int b *
* 返回: int c *
* 函数功能: 执行加法运算 *
**************************************/
3. 一些该注意的地方:
3.1 加注释时,应使用/* ............. */ ,而尽量避免使用 //.........
3.2 注意缩进,使用4个空格,而避免直接使用tab键
3.3 括号必须对齐(当然,不对齐的话,编辑器一般会有提示)
4. 最近比较常用的注释框架:
4.1 HeadFileDescription
/**************************************************************************************************
* Header File
*
* File Name : FN_FileName.c/ FN_FileName.h
* Copyright : 2016 ~ 2020 Elvin Corporation, All rights Reserved.
* Module Name : Display
*
* CPU : X86
* RTOS : windows7 32bit
*
* Create Date : 2016/04/21
* Author/Corporation : Elvin/ESYS Company
*
* Abstract Description : some function about seqlist.
*
*------------------------Revision History------------------------------------------------
* No Version Date Revised By Item Description
* 1 0.02 2016/04/21 Elvin Seqlist Just a test
**************************************************************************************************/
/**************************************************************************************************
* Muti-Include-Prevent Section
**************************************************************************************************/
#ifndef _FN_FILENAME_H
#define _FN_FILENAME_H
/**************************************************************************************************
* Debug switch Section
**************************************************************************************************/
#define D_FILENAME_BASE
/**************************************************************************************************
* Include File Section
**************************************************************************************************/
/* Perhaps there are some file will be Included */
/* No file will be Included */
#include "IncFile.h"
/**************************************************************************************************
* Macro Define Section
**************************************************************************************************/
/* Perhaps there are some Macro will be defined */
/* No Macro will be defined */
#define MAX_TIMER_OUT
/**************************************************************************************************
* Struct Define Section
**************************************************************************************************/
/* Perhaps there are some Struct be defined */
/* No Struct will be defined */
typedef struct Seqlist
{
int capacity;
int length;
}Seqlist_st, * Seqlist_pst;
/**************************************************************************************************
* Protoryppe Declare Section
**************************************************************************************************/
Seqlist_pst SeqlistCreate(int capacity);
#endif
4.2 SourceFileDescription
/**************************************************************************************************
* Source File
*
* File Name : FN_FileName.c
* Copyright : 2016 ~ 2020 Elvin Corporation, All rights Reserved.
* Module Name : Display
*
* CPU : X86
* RTOS : windows7 32bit
*
* Create Date : 2016/04/21
* Author/Corporation : Elvin/ESYS Company
*
* Abstract Description : some function about seqlist.
*
*------------------------Revision History------------------------------------------------
* No Version Date Revised By Item Description
* 1 0.02 2016/04/21 Elvin Seqlist Just a test
**************************************************************************************************/
/**************************************************************************************************
* Debug switch Section
**************************************************************************************************/
#define D_FILENAME_BASE
/**************************************************************************************************
* Include File Section
**************************************************************************************************/
/* Perhaps there are some file will be Included */
/* No file will be Included */
#include "IncFile.h"
/**************************************************************************************************
* Macro Define Section
**************************************************************************************************/
/* Perhaps there are some Macro will be defined */
/* No Macro will be defined */
#define MAX_TIMER_OUT
/**************************************************************************************************
* Struct Define Section
**************************************************************************************************/
/* Perhaps there are some Struct be defined */
/* No Struct will be defined */
typedef struct Seqlist
{
int capacity;
int length;
}Seqlist_st, * Seqlist_pst;
/**************************************************************************************************
* Prototype Declare Section
**************************************************************************************************/
Seqlist_pst SeqlistCreate(int capacity);
/**************************************************************************************************
* Global Variable Declare Section
**************************************************************************************************/
/* Perhaps there are some Global Variable be defined */
/* No Global Variable will be defined */
extern unsigned int SeqlistNode;
/**************************************************************************************************
* File Static Variable Declare Section
**************************************************************************************************/
/*
4000
Perhaps there are some Static Variable be defined */
/* No Static Variable will be defined */
static unsigned int SeqlistStatus;
/**************************************************************************************************
* Function Declare Section
**************************************************************************************************/
Seqlist_pst SeqlistCreate(int capacity)
{
Seqlist_pst slist = NULL;
return slist;
}
相关文章推荐
- 代码编程规范之linux下编程
- [zz]Linux 内核 C 编程规范
- Linux操作以及c编程规范 、附带个问题
- Linux项目组编程规范
- linux串口编程 非规范模式 read()问题
- linux串口编程 非规范模式 read()问题
- linux串口编程 非规范模式 read()问题
- linux下C编程规范
- Linux 高性能服务器编程——Linux服务器程序规范
- 1、Linux编程规范-C Coding Standard
- linux串口编程 非规范模式 read()问题
- linux串口编程 非规范模式 read()问题
- Linux 高性能服务器编程——Linux服务器程序规范
- linux串口编程 非规范模式 read()问题
- linux串口编程 非规范模式 read()问题
- LS5-linux编程规范之学习笔记
- Linux 高性能服务器编程——Linux服务器程序规范
- Linux_2.1_编程规范
- linux 内核编程风格规范
- Linux 内核 C 编程规范