《C语言深度解剖》中的.c/.h 程序模板及函数注释风格
生活随笔
收集整理的這篇文章主要介紹了
《C语言深度解剖》中的.c/.h 程序模板及函数注释风格
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
編程規范和變量命令規范對于代碼的可閱讀性、可維護性有著很大的影響。編程規范有很多,大公司也會制定自己公司的編程規范,如《華為技術有限公司c語言編程規范》等。對于個人編程來說沒必要將自己編寫的代碼按照每一種編程規范去規范,因為不同的?規范中可能會有相互沖突的地方。個人可以選擇編寫的代碼閱讀起來比較舒服的規范,并一直堅持使用,如此則可以形成自己的編程風格(重點不在于你知道多少種規范的,而是要在實際編程中去使用它,不必拘泥于某一種規范,可以綜合幾個規范選擇適合自己的部分堅持使用)。
這里我使用的是陳正沖老師《C語言深度解剖》中的編程規范,并根據自己的實際使用做了些改動,具體如下。
頭文件模板
/******************************************* * File Name : FN_FileName.h * CopyRight : All Rights Reserved. * Module Name : * * CPU : STM32F103C8T6 * RTOS : RT-THREAD * * Creat Date : 2020/09/17 * Author/Corporation : Jason/DJI * * Abstract Description: * * --------------Revision History---------------- * NO Version Date Revised by Description * 1 V0.0 2020/09/17 Jason the first verison * *******************************************//******************************************* * Multi-Include-Prevent Section *******************************************/ #ifndef __FN_FILENAME_H #define __FN_FILENAME_H /******************************************* * Debug switch Section *******************************************//******************************************* * Include File Section *******************************************//******************************************* * Macro Define Section *******************************************//******************************************* * Struct Define Section *******************************************//******************************************* * Prototype Declare Section *******************************************/#endif源文件模板
/******************************************* * File Name : FN_FileName.c * CopyRight : All Rights Reserved. * Module Name : * * CPU : STM32F103C8T6 * RTOS : RT-THREAD * * Creat Date : 2020/09/17 * Author/Corporation : Jason/DJI * * Abstract Description: * * --------------Revision History---------------- * NO Version Date Revised by Description * 1 V0.0 2020/09/17 Jason the first verison * *******************************************//******************************************* * Debug switch Section *******************************************//******************************************* * Include File Section *******************************************//******************************************* * Macro Define Section *******************************************//******************************************* * Struct Define Section *******************************************//******************************************* * Prototype Declare Section *******************************************//******************************************* * Global Variable Declare Section *******************************************//******************************************* * File Static Variable Define Section *******************************************//******************************************* * Function Define Section *******************************************/函數注釋模板
/******************************************* * Function Name : delay_us * Creat Date : 2020/09/17 * Author/Corporation : Jason/DJI * Description : uS levels of delay, use static define delay_us() means this funtion is only used in this file * Para : nus: the uS delay time * Return Code : null ------------------------------ * Revision History * Date Revised by Description * 2020/09/17 Jason the first verison *******************************************/ static void delay_us(uint16_t nus) { }/******************************************* * Function Name : Get_ADS1115_Volt * Creat Date : 2020/09/17 * Author/Corporation : Jason/DJI * Description : get ADC convert result from ADS115 * Para : channel: ADS1115 channel wants to readtimes: read how many times * Return Code : volt: the average of several results, unit is mV ------------------------------ * Revision History * Date Revised by Description * 2020/09/17 Jason the first verison *******************************************/ int16_t Get_ADS1115_Volt(enum ADS1115_Channel channel, int16_t times) { }?
總結
以上是生活随笔為你收集整理的《C语言深度解剖》中的.c/.h 程序模板及函数注释风格的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 使用IAR软件的搜索快捷键出现中文繁体现
- 下一篇: spring源码分析-core.io包里