STM32 Development Notes 97: C ++ language naming conventions

SCM Model: STM32F091RCT6


Naming the C ++ language recorded in this article.

1, file names are in lowercase letters manner, with between multiple English words "_" to be divided;

2, macro definitions are used in capital letters manner, with between multiple English words "_" to be divided;

3, the custom data type are lowercase letters manner, among the plurality of English words using "_" to be divided;

4, the class name of the first letters written in C, the subsequent use of Hungarian notation, the first letter capitalized, in case abbreviation words, then according to the English naming spelling, such as an LED is an abbreviation of the word, but English specification can be written led or Led, then class name with CLed said, while HAL is an acronym for hardware mapping layer, is represented by a full English capital, when used, is used CHAL named;

5, a class object class declaration, the first letter of C can be removed, e.g. CLed named object directly to Led;

6, variable names follow the Hungarian notation, start with the prefix after the prefix plus "_" followed accurately represent the actual meaning of the variables more English words, word capitalized, in case the abbreviation of words, written in English in accordance with norms spelling, for example, ms is the abbreviation of the word, English lowercase, the variable named u16_ms;

7, bool variable named type, preceded by the prefix b, back without "_", e.g. bMilliSecond_1000, bResult the like,

8, the name of the variable such as complex data types, such as structures, unions, enumerations, prefix may be named;

9, pointer variables, may be employed prefix p, back without "_", e.g. pData.

10, use a single line comment "//" represents plus one space, for example, "// main function";

11, the following is the VS Code, the user code segments are provided with CPP file info file:

{
	"Structure information for .h file": {
		"prefix": "Structure for .h file",
		"body": [
	 		"/**",
			"******************************************************************************",
			"* @file        .h",
			"* @brief        头文件",
			"* @author      snmplink",
			"* @version     使用Git进行版本控制",
			"* @date        2020-  创建该文件",
			"******************************************************************************",
			"* @attention",
			"*",
			"* <h2><center>&copy; Copyright (c) 2020-2030 snmplink.",
			"* All rights reserved.</center></h2>",
			"*",
			"* 开发文档:https://snmplink.blog.csdn.net/",
			"* ",
			"* github:https://github.com/snmplink",
			"* ",
			"* 码云:https://gitee.com/snmp123452",
			"* ",
			"* License. You may obtain a copy of the License at:",
			"*                        opensource.org/licenses/BSD-3-Clause",
			"*",
			"******************************************************************************",
			"*/",
			"",
			"#ifndef _H_",
			"#define _H_",
			"",
			"#include \".h\"",
			"",
			"#ifdef __cplusplus",
			"extern \"C\"{",
			"#endif",
			"",
			"class ",
			"{",
			"public:",
			"",
			"};",
			"",
			"#ifdef __cplusplus",
			"}",
			"#endif",
			"#endif"
		],
		"description": "头文件结构信息"
	},
	
	"Structure information for .cpp file": {
		"prefix": "Structure for .cpp file",
		"body": [
	 		"/**",
			"******************************************************************************",
			"* @file        .cpp",
			"* @brief        源文件",
			"* @author      snmplink",
			"* @version     使用Git进行版本控制",
			"* @date        2020-  创建该文件",
			"******************************************************************************",
			"* @attention",
			"*",
			"* <h2><center>&copy; Copyright (c) 2020-2030 snmplink.",
			"* All rights reserved.</center></h2>",
			"*",
			"* 开发文档:https://snmplink.blog.csdn.net/",
			"* ",
			"* github:https://github.com/snmplink",
			"* ",
			"* 码云:https://gitee.com/snmp123452",
			"* ",
			"* License. You may obtain a copy of the License at:",
			"*                        opensource.org/licenses/BSD-3-Clause",
			"*",
			"******************************************************************************",
			"*/"
		],
		"description": "CPP源文件结构信息"
	}
}

 

 

 

Published 425 original articles · won praise 1113 · Views 830,000 +

Guess you like

Origin blog.csdn.net/qingwufeiyang12346/article/details/104133409