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、需要對外公開的常量放在頭文件中,不需要對外公開的常量放在定義文件的頭部。