本文介绍了展开宏内doxygen注释打印软件版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我有一些C ++代码库,用doxygen记录,并使用GNU make构建。 版本信息集中在makefile中,其中有以下内容:在我的makefile中,CFLAGS添加以下定义:这使我能够获取代码中的版本,如下所示: #define STR_EXPAND(tok)#tok #define STR(tok)STR_EXPAND(tok) int main { cout<< 软件版本为} 现在,我想要的是在doxygen生成的html文件中: 我设法导出makefile变量到doxygen配置文件中:( edit :doxygen是从makefile通过make-doc目标调用的)但是,如果我尝试在doxygen \mainpage命令这样,它失败,因为(当然),宏名称不在评论中展开... / ** \mainpage这是doc Current版本是$(APP_VERSION) - 或 - ...是APP_VERSION * / 问题 您知道如何在doxygen评论中展开 ?这可以通过对在makefile中包含注释的文件进行一些sed处理来完成,但也许这可以直接用doxygen解决? 句柄版本控制(除了VCS提供的自动版本控制工具外,我的意思是),版本ID在文件中是唯一定义的,因此它可以通过软件构建系统和文档构建系统来获取。 li> 相关:如何显示定义的值 解决方案您需要使用make的export功能,即一个非常简单的make文件 project_name = FooBar export project_name all: doxygen Doxyfile 将允许您在C ++中使用以下注释 / *! \mainpage项目$(project_name)Lorem ipsum dolor 我可以看到这成为一个PITA一套出口,但它是一个相当简单的方法来做。或者,您可以运行doxygen从一个单独的BASH脚本中的所有导出,以避免污染您的Makefile太多。 I have some C++ code base, documented with doxygen, and build with GNU make.Version information is centralized in makefile, where I have something like:In my makefile, the CFLAGS add the following define:This enables me to get the version in code, like this:#define STR_EXPAND(tok) #tok#define STR(tok) STR_EXPAND(tok)int main(){ cout << "software version is << STR(APP_VERSION) << endl;}Now, what I would like is to have this in the doxygen-produced html files:I managed to export the makefile variable into the doxygen configuration file with:(edit: doxygen is called from makefile, through a 'make-doc' target)But then, if I try in the doxygen \mainpage command something like this, it fails, because (of course), macro names don't get expanded in comments.../**\mainpage this is the docCurrent version is $(APP_VERSION) -- or -- ... is APP_VERSION*/QuestionsDo you know of a way to "expand" that macro in the doxygen comments ? This could be done by some sed processing on the file holding the comment in the makefile, but maybe this can be solved directly with doxygen ?How do other projects handle versioning (besides automatic versioning tool that VCS provide, I mean), in a way that the version id is uniquely defined in a file, so it can be fetched both by software build system and documentation build system.Related: How to display a defined value 解决方案 You need to use the "export" functionality of make ie a very simple make file withproject_name=FooBarexport project_nameall: doxygen DoxyfileWill allow you to use the following comments in C++/*! \mainpage Project $(project_name) Lorem ipsum dolorI can see this becoming a PITA with a large set of exports but it's a fairly simple way to do it. Alternatively you could run doxygen from a separate BASH script with all the exports in it to avoid polluting your Makefile too much. 这篇关于展开宏内doxygen注释打印软件版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-16 20:47