当前位置:网站首页>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
边栏推荐
- 22-05-26 Xi'an interview question (01) preparation
- Install third-party libraries such as Jieba under Anaconda pytorch
- Summary of methods for counting the number of file lines in shell scripts
- State compression DP acwing 291 Mondrian's dream
- 20220630 learning clock in
- LeetCode 513. 找树左下角的值
- 传统企业数字化转型需要经过哪几个阶段?
- 【点云处理之论文狂读前沿版9】—Advanced Feature Learning on Point Clouds using Multi-resolution Features and Learni
- Complex character + number pyramid
- On the setting of global variable position in C language
猜你喜欢

拯救剧荒,程序员最爱看的高分美剧TOP10

AcWing 786. Number k

dried food! What problems will the intelligent management of retail industry encounter? It is enough to understand this article

Six dimensional space (C language)

With low code prospect, jnpf is flexible and easy to use, and uses intelligence to define a new office mode

LeetCode 241. 为运算表达式设计优先级

求组合数 AcWing 885. 求组合数 I

LeetCode 535. TinyURL 的加密与解密

Education informatization has stepped into 2.0. How can jnpf help teachers reduce their burden and improve efficiency?

Gif remove blank frame frame number adjustment
随机推荐
Introduction to the basic application and skills of QT
AcWing 785. Quick sort (template)
LeetCode 871. 最低加油次数
[point cloud processing paper crazy reading frontier version 8] - pointview gcn: 3D shape classification with multi view point clouds
Using variables in sed command
[point cloud processing paper crazy reading frontier version 10] - mvtn: multi view transformation network for 3D shape recognition
浅谈企业信息化建设
Method of intercepting string in shell
Character pyramid
We have a common name, XX Gong
记忆化搜索 AcWing 901. 滑雪
Excel is not as good as jnpf form for 3 minutes in an hour. Leaders must praise it when making reports like this!
LeetCode 57. 插入区间
dried food! What problems will the intelligent management of retail industry encounter? It is enough to understand this article
[point cloud processing paper crazy reading classic version 8] - o-cnn: octree based revolutionary neural networks for 3D shape analysis
【点云处理之论文狂读经典版11】—— Mining Point Cloud Local Structures by Kernel Correlation and Graph Pooling
TP5 multi condition sorting
Vscode connect to remote server
【点云处理之论文狂读经典版14】—— Dynamic Graph CNN for Learning on Point Clouds
Arbre DP acwing 285. Un bal sans patron.