华为的编程规范和范例华为的编程规范和范例华为的编程规范和范例华为的编程规范和范例华为的编程规范和范例华为的编程规范和范例华为的编程规范和范例华为的编程规范和范例
#define MAX_ACT_TASK_NUMBER 1000 /* active statistic task number */
¹2-10:数据结构声明(包括数组、结构、类、枚举等),如果其命名不是充分自注释的,必须加以注释。对数据结构的注释应放在其上方相邻位置,不可放在下面;对结构中的每个域的注释放在此域的右方。
示例:可按如下形式说明枚举/数据/联合结构。
/* sccp interface with sccp user primitive message name */ enum SCCP_USER_PRIMITIVE {
N_UNITDATA_IND, /* sccp notify sccp user unit data come */ N_NOTICE_IND, /* sccp notify user the No.7 network can not */ /* transmission this message */
N_UNITDATA_REQ, /* sccp user's unit data transmission request*/ };
¹2-11:全局变量要有较详细的注释,包括对其功能、取值范围、哪些函数或过程存取它以及存取时注意事项等的说明。
示例:
/* The ErrorCode when SCCP translate */
/* Global Title failure, as follows */ // 变量作用、含义 /* 0 - SUCCESS 1 - GT Table error */
/* 2 - GT error Others - no use */ // 变量取值范围 /* only function SCCPTranslate() in */ /* this modual can modify it, and other */ /* module can visit it through call */
/* the function GetGTTransErrorCode() */ // 使用方法 BYTE g_GTTranErrorCode; ¹2-12:注释与所描述内容进行同样的缩排。
说明:可使程序排版整齐,并方便注释的阅读与理解。 示例:如下例子,排版不整齐,阅读稍感不方便。 void example_fun( void ) {
/* code one comments */ CodeBlock One