You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Doxygen 1.9.5因前向声明导致文档生成异常问题求助

Doxygen 1.9.5 前向声明导致文档生成异常

问题现象

  • 类列表中,Class A的头文件描述未显示
    类列表:fileA描述未显示
  • fileA的版权和作者信息错误显示在成员函数文档中
    成员函数文档中显示fileA版权信息
  • 将前向声明替换为#include指令后,文档生成恢复正常,但项目存在循环包含问题,必须使用前向声明
  • Class B无此异常,文档显示符合预期
    Class B文档正常显示

使用版本:Doxygen 1.9.5

示例源代码

fileA.h 源码

/*******************************************************************************
 * @copyright        Copyright (c) 2021
 *******************************************************************************
 * @author  Mr. Embedded
 *
 * @brief This description and the copyright and author info
 * shall be displayed in the doxygen "class Referece" in the section "Detailed Description"
 * for all classes that are declared in this header-file.
 *
 ******************************************************************************/
#ifndef _FILE_A_H
#define _FILE_A_H

// forward declaration
class B;

class A{
public:
   B *b;
   void test(void);
};

#endif

fileA.cpp 源码

/*******************************************************************************
 * @copyright        Copyright (c) 2021
 *******************************************************************************
 * @author  Mr. Embedded
 *
 ******************************************************************************/

#include "fileA.h"
#include "fileB.h"

/*******************************************************************************
 * @brief test Dummy
 ******************************************************************************/
void A::test()
{
   b = new B;
   b->test();
}

fileB.h 源码

/*******************************************************************************
 * @copyright        Copyright (c) 2021
 *******************************************************************************
 * @author  Mr. Embedded
 *
 * @brief This description and the copyright and author info
 * shall be displayed in the doxygen "class Referece" in the section "Detailed Description"
 * for all classes that are declared in this header-file.
 *
 ******************************************************************************/
#ifndef _FILE_B_H
#define _FILE_B_H

class B{
public:
   void test(void);
};

#endif

fileB.cpp 源码

/*******************************************************************************
 * @copyright        Copyright (c) 2021
 *******************************************************************************
 * @author  Mr. Embedded
 *
 ******************************************************************************/

#include "fileB.h"

/*******************************************************************************
 * @brief test Dummy
 ******************************************************************************/
void B::test()
{
}

Doxyfile 与默认配置的差异

$ doxygen -x doxyfile
# Difference with default Doxyfile 1.9.5 (87846a24ba5d96a548e5e1a377c2ff078a77dd77)
SHORT_NAMES            = YES
JAVADOC_AUTOBRIEF      = YES
JAVADOC_BANNER         = YES
MULTILINE_CPP_IS_BRIEF = YES
EXTENSION_MAPPING      = h=C++
EXTRACT_ALL            = YES
EXTRACT_PRIVATE        = YES
EXTRACT_STATIC         = YES
EXTRACT_LOCAL_METHODS  = YES
EXTRACT_ANON_NSPACES   = YES
SHOW_NAMESPACES        = NO
INPUT                  = fileA.h \
                         fileA.cpp \
                         fileB.h \
                         fileB.cpp
RECURSIVE              = YES
SOURCE_BROWSER         = YES
DIR_GRAPH_MAX_DEPTH    = 10

内容的提问来源于stack exchange,提问作者MaxM.

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.19 09:50:24