代码开发注释规范

代码注释规范

下面为学习借鉴总结的一些不错的代码编写规范,记录在册,供自己遵循和回顾。
一、C/C++头文件(.h)
这里用来编写包括:宏定义、自定义类型、函数声明、类定义
1、文件描述
/*****************************************************************      个人习惯注释边长66个字符
* (c) Developed by Li Yingda. All rights reserved.
*
* @file: SysTick.h
*
* version: 1.1	2016-3-14
*
* This file contains the functions about the management of system
* tick timer which support parallel processing. Programmer can
* add as many tasks as the space and time permit to this modular
* by function SetTimeout() conveninently, so that programmer can
* get rid of the restriction of the number of system timer.
*
* Tips: The following function tick_interrupt should be added into
	the function SysTick_Handler in the object file stm32f10x_it.c
*****************************************************************/
2、头文件include信息
/************************ include files *************************/
#include "stm32f10x.h"
3、宏定义信息
/*********************** macro definitions **********************/
#define CALL_BACK_HANDLE callBackNode*
4、结构体、枚举、函数指针、自定义类型
/*********************** type definitions ***********************/
typedef void (*callBack)(void);
5、全局变量声明
/********************* variable declarations ********************/
int count;
6、类定义
/********************** class declarations **********************/
class node
{
private:
	int count;
public:
	get();
};
7、函数声明
/********************* function declarations ********************/
void SysTick_Init(void);
二、C/C++的.c/.cpp文件
这里用来编写:声明全局变量、函数的具体定义
1、文件描述
/*****************************************************************
* (c) Developed by Li Yingda. All rights reserved.
*
* @file: SysTick.h
*
* version: 1.1	2016-3-14
*
* This file contains the functions about the management of system
* tick timer which support parallel processing. Programmer can
* add as many tasks as the space and time permit to this modular
* by function SetTimeout() conveninently, so that programmer can
* get rid of the restriction of the number of system timer.
*
* Tips: The following function tick_interrupt should be added into
	the function SysTick_Handler in the object file stm32f10x_it.c
*****************************************************************/
2、头文件include信息
/************************ include files *************************/
#include "stm32f10x.h"
3、全局变量重声明
/********************* variable declarations ********************/
extern int count;
4、函数级注释、块注释、语句注释
/*****************************************************************
* This function can send a number to the server by GSM.
*
* @param	InstancePtr contains the pointer to the instance of the UART.
* @param	num is the number to be sent.
*
* @return	return TRUE if send successfully, otherwise FALSE
* @note		None.
*****************************************************************/
unsigned char TCP_Send_Int(XUartLite *InstancePtr, int num){
	unsigned char num_str[20];
	int count;
	/*
	* 块注释
	*/
	count = int_to_string(num, num_str);
	return TCP_Send(InstancePtr, num_str, count);	//语句注释
}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值