简体   繁体   English

在C ++标头中具有未声明函数的Doxygen注释

[英]Doxygen comments with undeclared functions in C++ headers

I've got a code with member functions defined in the .cpp file that are not declared in the .h file. 我有一个代码,其成员函数在.cpp文件中定义,但未在.h文件中声明。 Contrary to what I would expect, it compiles without any problem. 与我期望的相反,它可以毫无问题地进行编译。

I want to generate some documentation with Doxygen but the comments I add before the member functions that are undeclared in the header file don't seem to be recognized by Doxygen. 我想使用Doxygen生成一些文档,但是我在头文件中未声明的成员函数之前添加的注释似乎无法被Doxygen识别。

Is there any workaround to this problem, other than defining the functions in the header file? 除了在头文件中定义函数以外,是否有任何解决此问题的方法?

I've got a code with member functions defined in the .cpp file that are not declared in the .h file. 我有一个代码,其成员函数在.cpp文件中定义,但未在.h文件中声明。 Contrary to what I would expect, it compiles without any problem. 与我期望的相反,它可以毫无问题地进行编译。

Do you mean this? 你是这个意思吗

// Foo.h
class Foo
{
  void bar ();
  // no method "meh".
};

// Foo.cpp
int Foo::meh (const std::string& message)
{
   // ...
};

Because that shouldn't compile. 因为那不应该编译。

If you mean this: 如果您的意思是:

// Foo.h
void bar ();
// no function "meh".

// Foo.cpp
int meh (const std::string& message)
{
   // ...
}

Then that's perfectly OK (free functions don't require a declaration in a header file). 这样就完全可以了(自由函数不需要在头文件中声明)。


I want to generate some documentation with Doxygen but the comments I add before the member functions that are undeclared in the header file don't seem to be recognized by Doxygen. 我想使用Doxygen生成一些文档,但是我在头文件中未声明的成员函数之前添加的注释似乎无法被Doxygen识别。

This depends on your Doxygen configuration. 这取决于您的Doxygen配置。 Make sure you set the INPUT_PATTERNS setting to include both source files and header files. 确保将INPUT_PATTERNS设置设置为同时包含源文件和头文件。 Also make sure that free-standing function commands explicitly refer to some symbol (eg use the @fn meh command to document a meh function). 还要确保独立的功能命令明确引用某个符号(例如,使用@fn meh命令记录meh函数)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM