标准化头文件与C语言的格式生成方法

liaojiededepan 2012-12-20 10:17:41
最近重温zigbee,看着TI的协议栈,发现TI怎么写软件写得那么的规范,hold不住,太舒服了心里痒痒

格式如下,我感觉这个格式肯定是软件自动生成,不是手工添加的,编译器是IAR
请教大虾,用什么软件可以生产如此规范头文件 c VS2010有没有这种功能

/**************************************************************************************************
Filename: comdef.h
Revised: $Date: 2010-07-28 08:42:48 -0700 (Wed, 28 Jul 2010) $
Revision: $Revision: 23160 $

Description: Type definitions and macros.


Copyright 2004-2008 Texas Instruments Incorporated. All rights reserved.

IMPORTANT: Your use of this Software is limited to those specific rights
granted under the terms of a software license agreement between the user
who downloaded the software,

Should you have any questions regarding your right to use this Software,
contact Texas Instruments Incorporated at www.TI.com.
**************************************************************************************************/

/**************************************************************************************************
Filename: OSAL.c
Revised: $Date: 2011-05-27 09:03:48 -0700 (Fri, 27 May 2011) $
Revision: $Revision: 26134 $

Description: This API allows the software components in the Z-stack to be written
independently of the specifics of the operating system, kernel or tasking
environment (including control loops or connect-to-interrupt systems).
**************************************************************************************************/

/*********************************************************************
* INCLUDES
*/
...全文
300 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
mymtom 2012-12-29
  • 打赏
  • 举报
回复
引用 3 楼 liaojiededepan 的回复:
大湿,能否分享一下宏,谢谢 仔细看里面时间是自动添加的 版本也是随着修改自动更新的
版本和日期是CVS/SVN等版本工具在检出时自动生成的。 文件里写成 Revised: $Date$ Revision: $Revision$ 检出时就自动变成实际的日期和版本号了。 Revised: $Date: 2010-07-28 08:42:48 -0700 (Wed, 28 Jul 2010) $ Revision: $Revision: 23160 $ 请参考 CVS Keyword substitution http://www.cs.utah.edu/dept/old/texinfo/cvs/cvs_16.html
BeanJoy 2012-12-21
  • 打赏
  • 举报
回复
引用 3 楼 liaojiededepan 的回复:
大湿,能否分享一下宏,谢谢 仔细看里面时间是自动添加的 版本也是随着修改自动更新的
VC中,Tools-Macro...-Edit,然后宏名和描述随你,然后输入以下内容:

'------------------------------------------------------------------------------
'FILE DESCRIPTION: 为开发环境添加批量注释或取消注释
'------------------------------------------------------------------------------

Sub SetSelNote() 'Sun DESCRIPTION : 过程SetSelNote用于将选中的文本转换为注释
	dim CurWin '当前获得的窗口
	set CurWin = ActiveWindow

	if CurWin.Type <> "Text" then '判断当前窗口是否是文本窗口
		MsgBox "当前窗口不是代码窗口"
	else
		NoteType = "//"

		BeginLine = ActiveDocument.Selection.TopLine
		EndLine	  = ActiveDocument.Selection.BottomLine
		
		if EndLine < BeginLine then	
			Line = BeginLine
			BeginLine = EndLine
			EndLine = Line
		else
			for row = BeginLine to EndLine
				ActiveDocument.Selection.GoToLine row
				ActiveDocument.Selection.SelectLine '选中当前行
				ActiveDocument.Selection = NoteType + ActiveDocument.Selection
			next

			ActiveDocument.Selection.GoToLine BeginLine
			for row = BeginLine to EndLine
				ActiveDocument.Selection.LineDown dsExtend
			next

		end if
	end if
end Sub

Sub CancelSelNote()
	dim CurWin '当前获得的窗口
	set CurWin = ActiveWindow

	if CurWin.type <> "Text" then '判断当前窗口是否是文本窗口
		MsgBox "当前窗口不是代码窗口"
	else
		BeginLine = ActiveDocument.Selection.TopLine
		EndLine	  = ActiveDocument.Selection.BottomLine

		if EndLine < BeginLine then	
			Line = BeginLine
			BeginLine = EndLine
			EndLine = Line
		else
			for row = BeginLine to  EndLine
				ActiveDocument.Selection.GoToLine row
				ActiveDocument.Selection.SelectLine '选中当前行
				SelBlock = ActiveDocument.Selection

				Trim( SelBlock )
				pos = instr( SelBlock, "//" )
				if pos <> 0 then
					RightBlock = Right( SelBlock, Len( SelBlock) - 2 )
					ActiveDocument.Selection = RightBlock
				end if
			next

			ActiveDocument.Selection.GoToLine BeginLine
			for row = BeginLine to EndLine
				ActiveDocument.Selection.LineDown dsExtend
			next

		end if
	end if
end Sub
然后保存。 然后选中某段代码,然后tools-marco...,选择SetSelNote,然后Run,就把选中的注释掉了。 当然,如果你再加模板代码,一样的。 然后,你就知道怎么用了。
liaojiededepan 2012-12-21
  • 打赏
  • 举报
回复
大湿,能否分享一下宏,谢谢 仔细看里面时间是自动添加的 版本也是随着修改自动更新的
赵4老师 2012-12-21
  • 打赏
  • 举报
回复
警惕语法糖在注释中藏身!
BeanJoy 2012-12-20
  • 打赏
  • 举报
回复
VS2008不知道,VC6上面有宏macro,写个宏想干嘛干嘛。
uniqueCNL 2012-12-20
  • 打赏
  • 举报
回复
自己做一个不就行了,生产原文件,然后用模板文件中的内容拷贝进去就OK了

24,854

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 工具平台和程序库
社区管理员
  • 工具平台和程序库社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧