`
xpp02
  • 浏览: 1014764 次
社区版块
存档分类
最新评论

文件结构

 
阅读更多

C语言文件名命名的规则

1、文件标识符分为两部分,即文件名前缀和后缀。文件名前缀的最前面要使用范围限定符——模块名(文件名)缩写。

2、采用小写字母命名文件,避免使用一些比较通俗的文件名,如:public.c 等。


C语言文件内容的一般规则

1、每个头文件和源文件的头部必须包含文件头部说明和修改记录。
源文件和头文件的头部说明必须包含的内容和次序如下:
/************************************************************************
* File Name : FN_FileName.c/ FN_FileName.h
* Copyright : 2003-2008 XXXX Corporation, All Rights Reserved.
* Module Name : Draw Engine/Display
*
* CPU : ARM7
* RTOS : Tron
*
* Create Date : 2008/10/01
* Author/Corporation : WhoAmI/your company name
**
Abstract Description : Place some description here.
**
-----------------------Revision History---------------------------------
* No Version Date Revised By Item Description
* 1 V0.95 08.05.18 WhoAmI abcdefghijklm WhatUDo
*
************************************************************************/

2、各个源文件必须有一个头文件说明,头文件各部分的书写顺序下:

其中Multi-Include-Prevent Section 是用来防止头文件被重复包含的。如下例:
#ifndef __FN_FILENAME_H
#define __FN_FILENAME_H
#endif
其中“FN_FILENAME”一般为本头文件名大写,这样可以有效避免重复,因为同一工程中不可能存在两个同名的头文件。
/************************************************************************
* File Name : FN_FileName.h
* Copyright : 2003-2008 XXXX Corporation, All Rights Reserved.
* Module Name : Draw Engine/Display
*
* CPU : ARM7
* RTOS : Tron
*
* Create Date : 2008/10/01
* Author/Corporation : WhoAmI/your company name
**
Abstract Description : Place some description here.
**
----------------------------------------Revision History---------------------------------
* No Version Date Revised By Item Description
* 1 V0.95 08.05.18 WhoAmI abcdefghijklm WhatUDo
*
************************************************************************/
/************************************************************************
* Multi-Include-Prevent Section
************************************************************************/
#ifndef __FN_FILENAME_H
#define __FN_FILENAME_H
/************************************************************************
* Debug switch Section
************************************************************************/
#define D_DISP_BASE
/************************************************************************
* Include File Section
************************************************************************/
#include "IncFile.h"
/************************************************************************
* Macro Define Section
************************************************************************/
#define MAX_TIMER_OUT (4)
/************************************************************************
* Struct Define Section
************************************************************************/
typedef struct CM_RadiationDose
{
unsigned char ucCtgID;
char cPatId_a[MAX_PATI_LEN];
}CM_RadiationDose_st, *CM_RadiationDose_pst;
/************************************************************************
* Prototype Declare Section
************************************************************************/
unsigned intMD_guiGetScanTimes(void);
…… #endif

3、源文件各部分的书写顺序如下:
/*************************************************************************
* File Name : FN_FileName.c
* Copyright : 2003-2008 XXXX Corporation, All Rights Reserved.
* Module Name : Draw Engine/Display
*
* CPU : ARM7
* RTOS : Tron
*
* Create Date : 2003/10/01
* Author/Corporation : WhoAmI/your company name
**
Abstract Description : Place some description here.
**
-----------------------Revision History---------------------------------
* No Version Date Revised By Item Description
* 1 V0.95 00.05.18 WhoAmI abcdefghijklm WhatUDo
*
************************************************************************/
/************************************************************************
* Debug switch Section
************************************************************************/
#define D_DISP_BASE
/************************************************************************
* Include File Section
************************************************************************/
#include "IncFile.h"
/************************************************************************
* Macro Define Section
************************************************************************/
#define MAX_TIMER_OUT (4)
/************************************************************************
* Struct Define Section
************************************************************************/
typedef struct CM_RadiationDose
{
unsigned char ucCtgID;
char cPatId_a[MAX_PATI_LEN];
}CM_RadiationDose_st, *pCM_RadiationDose_st;
/************************************************************************
* Prototype Declare Section
************************************************************************/
unsigned int MD_guiGetScanTimes(void);
/************************************************************************
* Global Variable Declare Section
************************************************************************/
extern unsigned int MD_guiHoldBreathStatus;
/************************************************************************
* File Static Variable Define Section
************************************************************************/
static unsigned int nuiNaviSysStatus;
/************************************************************************
* Function Define Section
************************************************************************/

4、需要对外公开的常量放在头文件中,不需要对外公开的常量放在定义文件的头部。

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics