如果您无法下载资料,请参考说明:
1、部分资料下载需要金币,请确保您的账户上有足够的金币
2、已购买过的文档,再次下载不重复扣费
3、资料包下载后请先用软件解压,在使用对应软件打开
C语言编程规范和约定排版•缩进•空行•空格•代码长度缩进if(1==reset_flag){•缩进量=4reset_state();}•用空格取代TABelse{for(n=1;n<20;n++){update_state();}}if(1==reset_flag){reset_state();}else{for(n=1;n<20;n++)update_state();}switch语句缩进voiddo_it(){switch(state){caseSTAT_A:…break;caseSTATE_B:case向左和switch对齐…break;default:bkbreak;}}程序标号s16_tdo_it(){flag=do_A();if((g)ERROR==flag)gotoexit;flag=do_B();if(ERROR==flag)gotoexit;…程序标号向左顶格exit:clear_memory();return‐1;}空行的使用不同的程序逻辑段落用空行分隔•函数之间加空行•变量申明和函数之间加空行•逻辑段落之间加空行u32_tread_flag;u32_tread_count;u32_twrite_flag;空行的u32_twrite_buff;u32_twrite_count;使用s32_tread_data(u8_t*buf,u32_tsize){u8_tflag;if(NULL==buf)return‐1;if((‐1==size)||(size>=MAX_READ_SIZE))return‐1;flag=read_port_status();…}s32_tread_data(u8_t*buf,u32_tsize){…}空格的使用(建议)•==、=、+、‐、*、/、>、<、>=、<=、:运算符两边加空格•标点符号前不加空格,后面加一个空格•if、for、while后面加空格•多重括号运算建议用空格表明层次关系if(1==resetflt_flag){reset_state();count=(count>=BUF_SIZE‐1)?BUF_SIZE‐1:count+1;}elseif(((1==status)||(2==status))&&((20==count)||(0==count))){for(n=1;n<20;n++){index=read_port()+(count*sizeof(data_t));}}空格的使用(建议)•‐>、.前后不加空格•++、‐‐前后不加空格(不要将++、‐‐用于有歧义的地方)•数组名和[]之间、函数名和()之间不加空格if(1==reset_flag){reset_state();ary[5]++;data‐>flag=1;status.overflow=1;}else{for(n=1;n<20;n++)index=read_port()+(count*sizeof(data_t));}空格的使用•指针指示符*和指针类型之间留空格,和指针名不留空格unsignedchar*p1,*p2;折行•每行不超过80列•在逻辑分割点折行•折行内容尽量对齐if(1==reset_flag){reset_state();count=(count>=BUF_SIZE‐1)?BUF_SIZE‐1:count+1;}elseif(((1==status)||(2==status)||(8==status))&&((20==count)||(0==count))&&(0==flag)){for(n=1;n<20;n++){index=read_port()+(count*sizeof(data_t));}}折行perm_count_msg.head.len=NO7_TO_STAT_PERM_COUNT_LEN+STAT_SIZE_PER_FRAM*sizeof(array);act_task_table[frame_id*STAT_TASK_CHECK_NUMBER+index].occupied=stat_poi[index].occupied;act_task_table[taskno].duration_true_or_false=SYS_get_sccp_statistic_state(stat_item);report_or_not_fla