Doxygen Document All Conditional Defines

2019-04-30 03:54发布

I have a project where I have a substantial amount of conditional defines for making cross platform development easier. However I'm having issues convincing Doxygen to extract all the defines, as it will only pick up ones that only happened to evaluate.

For example in the following snippet, Doxygen will document TARGET_X86_64 but not TARGET_ARM64.

#if defined(_M_ARM64) || defined(__arm64__) || defined(__aarch64__)
/** Build target is ARM64 if defined. */
#define TARGET_ARM64
#else
/** Build target is x86_64 if defined. */
#define TARGET_X86_64
#endif

Enabling EXTRACT_ALL did not help, and disabling preprocessing causes Doxygen to not document anything at all. How do I get doxygen to extract documentation for both cases?

1条回答
看我几分像从前
2楼-- · 2019-04-30 04:34

I made a "solution" that's verbose, but works. It's less awkward when you want to have #elseif statements than using just using pure #if statements. Although either would work.

First, define everything and not care about conditional logic.

/** Some define */
#define TARGET_DEFINE

/** Some other define */
#define OTHER_TARGET_DEFINE

Second, take the conditional logic that you originally used to create the defines and transform it to undefine logic.

#if !(ORIGINAL_LOGIC)
#undef TARGET_DEFINE
#endif

Lastly, change the conditional logic so that nothing is undefined when doxygen is doing the preprocessing.

#if !defined(DOXYGEN)
...
查看更多
登录 后发表回答