Doxygen不记录main.cpp中的主要功能

use*_*542 18 c++ program-entry-point doxygen

我有一个main.cpp,它包含一个struct,一些全局常量和一个main函数.

我运行doxygen,我在输出index.html中获得的唯一文档是我的struct.

我想doxygen将index.html文件记录到我的main()中.我做错了什么?

    /// Definition of Pi
    const auto Pi = 3.141592653589793238462643383279502884197169399;

    /// \struct myStruc
    /// \brief myStruc description
    ///
    struct myStruc
    {
         /// Comments inside myStruc
    };

    /// \file

    /// \brief  Main function
    /// \param  argc An integer argument count of the command line arguments
    /// \param  argv An argument vector of the command line arguments
    /// \return an integer 0 upon exit success
    int main(int argc, char** argv)
    {
        /// Comments I would like to be documented in as well
        return 0;
    }
Run Code Online (Sandbox Code Playgroud)

Chr*_*ris 25

这是因为您正在记录一个全局对象,默认情况下,doxygen不会记录.从doxygen手册(强调我的):

要记录C++类的成员,还必须记录该类本身.名称空间也是如此.要记录全局C函数,typedef,enum或预处理器定义,必须首先记录包含它的文件(通常这将是一个头文件,因为该文件包含导出到其他源文件的信息).

让我们重复一遍,因为它经常被忽略:要记录全局对象(函数,typedef,枚举,宏等),您必须记录定义它们的文件.换句话说,至少必须有一个

/*! \file */ 
Run Code Online (Sandbox Code Playgroud)

或者a

/** @file */ 
Run Code Online (Sandbox Code Playgroud)

该文件中的行.

因此,请尝试将以上两行中的一行添加到main.cpp文件中.