Doxygen не отображает макросы в модуле

Рейтинг: 0Ответов: 1Опубликовано: 10.03.2023

Написал следующий код:

/*****************************************************************//**
 * @file   main.cpp
 * @brief  main file of project
 *
 * @author bloody
 * @date   March 2023
 *********************************************************************/

#include <iostream>

using namespace std;

#pragma region core_arch
/**
 * @defgroup architecture_of_cpu
 * @brief In this group keeps macros which needs for detect architecture of cpu
 */
///@{

#if !defined(BMODULESNET_ARCH64) && !defined(BMODULESNET_ARCH32)
#if defined(__x86_64) || defined(__x86_64__) || defined(__amd64__) || defined(__amd64) || defined(_M_X64)
/**
 * @brief If architecture of cpu is x64, this macro will define
 * @ingroup architecture_of_cpu
 */
#define BMODULESNET_ARCH64

/**
 * @brief Keeps architecture of cpu.
 *
 * @details If your architecture is x64, this macro will equal to 64.
 * If your architecture is x86, this macro will equal to 32.
 *
 * @ingroup architecture_of_cpu
 */
#define BMODULESNET_ARCH 64

#elif defined(i386) || defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__) || defined(__i386) || defined(_M_IX86) || defined(_X86_) || defined(__THW_INTEL__) || defined(__I86__) || defined(__INTEL__)

/**
 * @brief If architecture of cpu is x86, this macro will define
 * @ingroup architecture_of_cpu
 */
#define BMODULESNET_ARCH32

/**
 * @brief Keeps architecture of cpu.
 *
 * @details If your architecture is x64, this macro will equal to 64.
 * If your architecture is x86, this macro will equal to 32.
 *
 * @ingroup architecture_of_cpu
 */
#define BMODULESNET_ARCH 32

#else
#error BModulesNetwork cannot detect the architecture of cpu
#endif
#endif // !BMODULESNET_ARCH64 && !BMODULESNET_ARCH32

///@}
#pragma endregion

int main()
{
    return 1;
}

Но когда я создаю документацию с помощью doxygen, я вижу это: image Хотя по идее в модуле должны быть ещё и макросы (В моём случае BMODULESNET_ARCH64 и BMODULESNET_ARCH 64). Если добавить определение макросов в начало, где объявляется модуль, то всё становится нормально:

/*****************************************************************//**
 * @file   main.cpp
 * @brief  main file of project
 *
 * @author bloody
 * @date   March 2023
 *********************************************************************/

#include <iostream>

using namespace std;

#pragma region core_arch
/**
 * @defgroup architecture_of_cpu
 * @brief In this group keeps macros which needs for detect architecture of cpu
 */
///@{

/**
 * @brief If architecture of cpu is x64, this macro will defined
 * @ingroup architecture_of_cpu
 */
#define BMODULESNET_ARCH64

/**
 * @brief Keeps architecture of your cpu.
 *
 * @details If your architecture is x64, this macro will equal to 64.
 * If your architecture is x86, this macro will equal to 32.
 *
 * @ingroup architecture_of_cpu
 */
#define BMODULESNET_ARCH 64

#if !defined(BMODULESNET_ARCH64) && !defined(BMODULESNET_ARCH32)
#if defined(__x86_64) || defined(__x86_64__) || defined(__amd64__) || defined(__amd64) || defined(_M_X64)
/**
 * @brief If architecture of cpu is x64, this macro will defined
 * @ingroup architecture_of_cpu
 */
#define BMODULESNET_ARCH64

/**
 * @brief Keeps architecture of your cpu.
 *
 * @details If your architecture is x64, this macro will equal to 64.
 * If your architecture is x86, this macro will equal to 32.
 *
 * @ingroup architecture_of_cpu
 */
#define BMODULESNET_ARCH 64

#elif defined(i386) || defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__) || defined(__i386) || defined(_M_IX86) || defined(_X86_) || defined(__THW_INTEL__) || defined(__I86__) || defined(__INTEL__)

/**
 * @brief If architecture of cpu is x86, this macro will defined
 * @ingroup architecture_of_cpu
 */
#define BMODULESNET_ARCH32

/**
 * @brief Keeps architecture of your cpu.
 *
 * @details If your architecture is x64, this macro will equal to 64.
 * If your architecture is x86, this macro will equal to 32.
 *
 * @ingroup architecture_of_cpu
 */
#define BMODULESNET_ARCH 32

#else
#error BModulesNetwork cannot detect the architecture of your cpu
#endif
#endif // !BMODULESNET_ARCH64 && !BMODULESNET_ARCH32

///@}
#pragma endregion

int main()
{
    return 1;
}

image2

Но в таком случае смысла от этих макросов 0. Как с этим бороться?

Ответы

▲ 0

В этом случае следует разделить объявления для компилятора С++ и компилятора doxygen. Для этого в препроцессоре doxygen задается специальное макро:

ENABLE_PREPROCESSING = YES
MACRO_EXPANSION      = YES
EXPAND_ONLY_PREDEF   = NO
PREDEFINED           = "DOXYGEN_INVOKED=1" 

А потом в коде все объявления с комментариями добавляются в соответствующий блок:

#if defined(DOXYGEN_INVOKED)

/** ...
#define BMODULESNET_ARCH32

/** ...
#define BMODULESNET_ARCH64

/** ...
#define BMODULESNET_ARCH

#else

настоящий код...

#endif // #if defined(DOXYGEN_INVOKED)