当前位置:网站首页>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
边栏推荐
- Common penetration test range
- [point cloud processing paper crazy reading classic version 14] - dynamic graph CNN for learning on point clouds
- Uc/os self-study from 0
- Debug debugging - Visual Studio 2022
- LeetCode 515. 在每个树行中找最大值
- 剑指 Offer II 029. 排序的循环链表
- Low code momentum, this information management system development artifact, you deserve it!
- 【点云处理之论文狂读经典版14】—— Dynamic Graph CNN for Learning on Point Clouds
- 干货!零售业智能化管理会遇到哪些问题?看懂这篇文章就够了
- PIC16F648A-E/SS PIC16 8位 微控制器,7KB(4Kx14)
猜你喜欢

Pic16f648a-e/ss PIC16 8-bit microcontroller, 7KB (4kx14)

Vs2019 configuration opencv3 detailed graphic tutorial and implementation of test code

剑指 Offer II 091. 粉刷房子

Gif remove blank frame frame number adjustment

树形DP AcWing 285. 没有上司的舞会

Sword finger offer II 029 Sorted circular linked list

excel一小时不如JNPF表单3分钟,这样做报表,领导都得点赞!

Vscode connect to remote server

Too many open files solution

一个优秀速开发框架是什么样的?
随机推荐
php public private protected
AcWing 785. 快速排序(模板)
一个优秀速开发框架是什么样的?
With low code prospect, jnpf is flexible and easy to use, and uses intelligence to define a new office mode
LeetCode 30. 串联所有单词的子串
Find the combination number acwing 886 Find the combination number II
LeetCode 30. Concatenate substrings of all words
Too many open files solution
AcWing 787. Merge sort (template)
dried food! What problems will the intelligent management of retail industry encounter? It is enough to understand this article
LeetCode 513. Find the value in the lower left corner of the tree
LeetCode 515. Find the maximum value in each tree row
String splicing method in shell
LeetCode 438. Find all letter ectopic words in the string
Using DLV to analyze the high CPU consumption of golang process
Introduction to the usage of getopts in shell
【点云处理之论文狂读前沿版9】—Advanced Feature Learning on Point Clouds using Multi-resolution Features and Learni
推荐一个 yyds 的低代码开源项目
求组合数 AcWing 886. 求组合数 II
Memory search acwing 901 skiing