当前位置:网站首页>C language programming specification
C language programming specification
2022-07-03 09:10:00 【BBQ】
C Language programming specifications
1. In a source file , The header file contains 、 Macro definition 、 Structure consortium definition 、 Function definitions and so on An area of your own Definition , Don't mix ;
2. The header file contains :
● If it is an official header ,#include <stdio.h>
● If it is a user header file :#include “bsp_can.h”
● reason :< > When compiling, you will first search from the system directory file ," " When compiling, you will first search from the user directory , Speed up compilation
3. Structure consortium definition :
● Both the structure and the consortium need to use typedef redefinition ;
● Redefined names are capitalized + Underline _ The way , It is similar to the naming of macro definitions , The name of structural weight definition is S_XXX(S Representative structure ), The name of combined weight definition is U_XXX(U On behalf of the Consortium );
● Variables defined in the structure , start 4 A space ( Or click TAB key );
● The opening curly braces own a line , The end curly bracket is followed by the redefined name ;
typedef struct
{
uint8_t h;
uint8_t s;
uint8_t v;
uint8_t res;
}S_HSV;
4. Variable naming :
● Naming of small hump , That is, the beginning letter of the first word is lowercase + The following words are capitalized
Such as :
int armorAreaMax;
● When defining pointer variables ,* Followed by the variable name ;
Such as :
int *armorAreaMax;
● When defining multiple variables with commas , There should be a blank space after the comma ;
Such as :
int armorAreaMax, armorAreaMin;
● Try not to use abbreviations , In addition to the Convention commonly known , Such as buf Instead of buffer Yes. ,tmp,rx,tx;
● Cannot use Chinese Pinyin ;
5. Macro definition
● Name in all uppercase and underlined form , It is best to () Cover up
Such as :
#define MAX_MUM (5)
6. Function definition
● Function names are in lowercase and underlined form
● In function definition ,() Multiple local variables defined inside , When using commas , There should be a blank space after the comma
7.if while And so on :
●if、while You should leave a blank space and add parentheses ;
● The things inside the parentheses should be close to the parentheses , Such as :
if (a <= 1)
You can't if( a <= 1 )
● Curly braces should own a line
●if What's in braces , Empty four or click TAB Key rewriting
● Block and block , Between functions , There is only one blank line
● Function definition even if invisible parameters , Better add void
Such as :
int swap(void)
{
}
attach B Station reference video :
https://www.bilibili.com/video/BV1Te411474Q?share_source=copy_web
边栏推荐
- 樹形DP AcWing 285. 沒有上司的舞會
- The difference between if -n and -z in shell
- TP5 order multi condition sort
- [point cloud processing paper crazy reading classic version 11] - mining point cloud local structures by kernel correlation and graph pooling
- LeetCode 30. 串联所有单词的子串
- Use of sort command in shell
- LeetCode 508. 出现次数最多的子树元素和
- AcWing 785. 快速排序(模板)
- [point cloud processing paper crazy reading classic version 8] - o-cnn: octree based revolutionary neural networks for 3D shape analysis
- AcWing 786. 第k个数
猜你喜欢
LeetCode 871. 最低加油次数
LeetCode 871. Minimum refueling times
剑指 Offer II 029. 排序的循环链表
20220630学习打卡
Basic knowledge of network security
Gif remove blank frame frame number adjustment
常见渗透测试靶场
【点云处理之论文狂读经典版12】—— FoldingNet: Point Cloud Auto-encoder via Deep Grid Deformation
【点云处理之论文狂读前沿版8】—— Pointview-GCN: 3D Shape Classification With Multi-View Point Clouds
LeetCode 30. 串联所有单词的子串
随机推荐
低代码起势,这款信息管理系统开发神器,你值得拥有!
高斯消元 AcWing 883. 高斯消元解线性方程组
状态压缩DP AcWing 291. 蒙德里安的梦想
TP5 multi condition sorting
LeetCode 515. Find the maximum value in each tree row
LeetCode 715. Range 模块
Common penetration test range
State compression DP acwing 291 Mondrian's dream
AcWing 786. Number k
【点云处理之论文狂读经典版10】—— PointCNN: Convolution On X-Transformed Points
我们有个共同的名字,XX工
Education informatization has stepped into 2.0. How can jnpf help teachers reduce their burden and improve efficiency?
With low code prospect, jnpf is flexible and easy to use, and uses intelligence to define a new office mode
On the setting of global variable position in C language
[point cloud processing paper crazy reading classic version 11] - mining point cloud local structures by kernel correlation and graph pooling
LeetCode 57. 插入区间
Gif remove blank frame frame number adjustment
Six dimensional space (C language)
LeetCode 324. 摆动排序 II
【点云处理之论文狂读经典版9】—— Pointwise Convolutional Neural Networks