Reputation: 2193
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?
Upvotes: 6
Views: 665
Reputation: 736
I like the idea from Marc Alff to add:
PREDEFINED = IN_DOXYGEN
In the doxygen configuration file. Then you can simply use the conditional logic and do not have redundant data:
#if defined(_M_ARM64) || defined(__arm64__) || defined(__aarch64__) || defined(IN_DOXYGEN)
/*! \brief Build target is ARM64 if defined. */
#define TARGET_ARM64
#endif
#if !(defined(_M_ARM64) || defined(__arm64__) || defined(__aarch64__)) || defined(IN_DOXYGEN)
/*! \brief Build target is x86_64 if defined. */
#define TARGET_X86_64
#endif
Upvotes: 0
Reputation: 2193
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)
...
Upvotes: 1