配置 Doxygen 以忽略源代码注释语言 (SAL)

Configure Doxygen to ignore the Source-Code Annotation Language (SAL)

我有一些用 Doxygen 记录的 类。此外,它们使用 Microsoft 的源代码注释语言 (SAL) 进行注释以支持静态代码分析。

//! The majestic class.
class Foo {
    //! \brief do something
    //! \param [out] pResult The result value is stored here.
    //! \returns The return value Succcess indicates success.
    _Success_(return == Success)
    virtual Result_t DoSomething(_Out_ uint32_t *pResult) = 0;
};

在这种情况下,Doxygen 报告警告:

argument 'pResult' of command @param is not found in the argument list of Foo::_Success_(return==Success)=0

所以,Doxygen 被注解语句弄糊涂了_Success_()。 如何隐藏 return 值注释 _Success_(return == Success) 去氧 不给源文件添加混乱?这样可以完成工作,但看起来太冗长了:

//! The majestic class.
class Foo {
    //! \brief do something
    //! \param [out] pResult The result value is stored here.
    //! \returns The return value Succcess indicates success.
    //! \cond INTERNAL
    _Success_(return == Success)
    //! \endcond
    virtual Result_t DoSomething(_Out_ uint32_t *pResult) = 0;
};

这可以通过配置 Doxygen 并保持源代码不变来实现吗?

Preprocessing章的doxygen手册中有一部分:

A typically example where some help from the preprocessor is needed is when dealing with the language extension from Microsoft: __declspec. The same goes for GNU's __attribute__ extension. Here is an example function.

在您的情况下,以下可能有效:

ENABLE_PREPROCESSING = YES
MACRO_EXPANSION = YES
EXPAND_ONLY_PREDEF = YES
PREDEFINED = _Success_(x)=