Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Doxygen Document All Conditional Defines

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?

like image 358
BlamKiwi Avatar asked Nov 09 '22 04:11

BlamKiwi


1 Answers

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)
...
like image 76
BlamKiwi Avatar answered Nov 15 '22 05:11

BlamKiwi