一、前言
1、在公司做项目时,使用公司的 C 语言编码规范即可。
2、如果公司没有编码规范,可以参考下面的编码规范,避免变量满天飞、代码混乱等问题,形成良好的编码习惯。
3、个人在私下进行学习时,也可以参考下面的编码规范。
二、C 语言个人编码规范
博客上面文章看起来比较乱,需要调整格式比较麻烦,个人直接做成了pdf,有需要的小伙伴可百度云盘自提。
通过网盘分享的文件:c语言个人编码规范.pdf
链接: https://pan.baidu.com/s/1paHekj4YcKKnF135U8iBzg?pwd=ds39 提取码: ds39
三、C 语言编码模板
1、template.c
//-----------------------------------------------------------------------------// Include//-----------------------------------------------------------------------------// self module#include"template.h"// other module// muc/soc module// rtos module// c standard lib module//-----------------------------------------------------------------------------// Macro Define//-----------------------------------------------------------------------------//-----------------------------------------------------------------------------// Extern Variable//-----------------------------------------------------------------------------//-----------------------------------------------------------------------------// Extern Function//-----------------------------------------------------------------------------//-----------------------------------------------------------------------------// Enum Define//-----------------------------------------------------------------------------//-----------------------------------------------------------------------------// Struct Define//-----------------------------------------------------------------------------//-----------------------------------------------------------------------------// Static Function Declaration//-----------------------------------------------------------------------------//-----------------------------------------------------------------------------// Static Variable//-----------------------------------------------------------------------------//-----------------------------------------------------------------------------// Global Variable//-----------------------------------------------------------------------------//-----------------------------------------------------------------------------// Static Function Implementation//-----------------------------------------------------------------------------//-----------------------------------------------------------------------------// Public Function Implementation//-----------------------------------------------------------------------------2、template.h
#ifndef__TEMPLATE_H__#define__TEMPLATE_H__//-----------------------------------------------------------------------------// Include//-----------------------------------------------------------------------------// self module// other module// muc/soc module// rtos module// c standard lib module#include<stdint.h>//-----------------------------------------------------------------------------// Macro Define//-----------------------------------------------------------------------------//-----------------------------------------------------------------------------// Extern Variable//-----------------------------------------------------------------------------//-----------------------------------------------------------------------------// Enum Define//-----------------------------------------------------------------------------//-----------------------------------------------------------------------------// Struct Define//-----------------------------------------------------------------------------//-----------------------------------------------------------------------------// Public Function Declaration//-----------------------------------------------------------------------------#endif