1、2.常用注释语法 注释写在对应的函数或变量前面。 简要注释和详细注释: /** * @brief Brief Description. * * Detailed Description */ 简要注释遇到一个空行或新的命令会结束,后面的就表示是详细注释。 JavaDoc风格下,自动会把第一个句号前的文本作为简要注释,后面的为详细注释。你也可以用空行把简要注释和详细注释分开。注意要设置JAVADOC_AUTOBRIEF设为YES。 为了注释一个类中的member,首先要对该类作注释。同样的问题上升到na
2、mespace。要注释一个全局的function,typedef,enum或preprocessor定义,你需要首先定义(只能用@file,因为文件不再任何东西里面,就只能用特殊命令实现了,而不像类、函数等,既可以在上方放注释,也可以用@class、@fn进行注释)包含它的文件。
(1)文件头注释
/** @file [file‐name]
*@brief brief description
* @author
* [@author
3、 @date
4、 @brief brief description
* @author 5、me> 6、iled description
* @remarks 7、函数返回值做解释
@note 表示注解,暴露给源码阅读者的文档
@remark 表示评论,暴露给客户程序员的文档
@since 表示从那个版本起开始有了这个函数
@deprecated 引起不推荐使用的警告
@see 表示交叉参考
函数的详细注释用@note代替详细注释,因为详细注释要空行隔开,容易忘记。
(4)成员注释
/**< 或//<用来注释成员,放在成员后面,格式如下:
int var; /**< Detailed description after the member */
int var 8、 ///< Brief description after the member
此语法对函数成员也适用。
(5)枚举类型注释
/** @brief Another enum, with inline docs */
enum AnotherEnum
{
V1, /**< value 1 */
V2 /**< value 2 */
};
一般约定:
(1)每个.h和.cpp文件的头部,必须要有简要注 9、释和详细注释,习惯用法如下:
/** @file
*@brief brief description
* @author 10、author 11、hor 12、在头文件的定义处进行简要注释,放在上方:
class Test
{
public:
/** @brief brief description */
int m_test(int a);
}
而在实现出给出详细注释:
/**
* @author 13、description>
* @return 14、scription */或右方用///< some brief description。
(5)每个枚举定义必须添加注释,格式如下:
/** Another enum, with inline docs */
enum AnotherEnum
{
V1, //< value 1
V2 //< value 2
};
下面是一个简单的例子,完全符合约定:
/** @file
* @brief a brief description for the file.
* @author soulmachin 15、e
* @date 2008/07/02
* @version 0.1
*
* detailed description for test.cpp
*/
/** @brief global function, no details
* @note some details about global function
*/
void global_test();
/** @class Test test.h "inc/test.h"
* @brief A test class.
*
* A more elaborate class desc 16、ription.
*/
class Test
{
public:
/** @brief A enum, with inline docs */
enum TEnum {
TVal1, /**< enum value TVal1. */
TVal2, /**< enum value TVal2. */
TVal3 /**< enum value TVal3. */
}
//这里Doxygen对enumPtr的处理有点问题
*enumPtr, ///< enum pointer.
enumVar; ///< enum variable.
/* 17、 @brief A constructor. */
Test();
/** @brief A destructor. */
~Test();
/** @brief a normal member taking two arguments and returning an integer value. */
int testMe(int a,const char *s);
/** @brief A pure virtual member.
* @param[in] c1 the first argument.
* @param[in] c2 the second 18、 argument.
* @see testMe()
*/
virtual void testMeToo(char c1,char c2) = 0;
int publicVar;//< a public variable.
/** @brief a function variable, note Details. */
int (*handler)(int a,int b);
/** @brief brief before delaration */
int m_func(int a);
};
/** A more elaborate descripti 19、on of the constructor. */
Test::Test()
{
}
/** A more elaborate description of the destructor. */
Test::~Test()
{
}
/**
* @param[in] a an integer argument.
* @param[in] s a constant character pointer.
* @return The test results
* @note Details.
* @par
* Another detail. 20、
* @see Test()
* @see ~Test()
* @see testMeToo()
* @see publicVar()
*/
int Test::testMe(int a,const char *s)
{
return 0;
}
/**
* @param[in] a a interger
* @return 0
* @note detailed description
* @remarks remarks,important
* @since 1.0
* @see testMeToo
*/
int Test::m_func(int a)
{
return 0;
}
* @note
* detailed description
*/
header‐file是类声明所在的头文件名字,header‐name是要显示的链接文字,一般为头文件的真实路径。
(3)函数注释
/**
* @brief brief description
* @author
* {@param[in|out]
* @date
* @note
* detailed description
*/
(3)全局变量和全局宏必须要有注释。
如果注释较短,则可以在上方用
/** @brief some brief description */或右方用
///< some brief description。
进行简要注释。
(4)任何函数都必须要有简要注释和详细注释,习惯用法如下:
/**
* @brief brief description
* @aut
* @param[in|out]
* @param [in|out]






