0

I have a lot of code doing conditional compilation based on defines that come from the compiler, not any definitions in the code itself or external headers. For example, quite frequently I have things such as:

#if defined _MSC_VER || defined __ICL
// A lot of freakin code
#elif defined __GNUC__  || defined __ICC
// A bunch more here
#else
#error "Unsupported environment"
#endif

I need to generate documentation for all the code inside the platofm/compiler-specific sections, but I cannot simply set ENABLE_PREPROCESSING to NO because it must be YES for INCLUDE_GRAPH and INCLUDED_GRAPH to work, according to the documentation.

So, how do I do this?

4

1 回答 1

1

You'd first have to define a macro DOXYGEN or similar in the "predefined" section of the doxygen configuration. Then you'd have to split up the #elif in separate #if and keep track of the fact that you found one valid configuration.

#if defined _MSC_VER || defined __ICL || defined DOXYGEN
#define WE_FOUND_SOME
// A lot of freakin code
#endif
#if defined __GNUC__  || defined __ICC || defined DOXYGEN
#define WE_FOUND_SOME
// A bunch more here
#endif
#ifndef WE_FOUND_SOME
# error "Unsupported environment"
#endif

But beware that if these different parts define the same functions or macros, that doxygen will easily get lost.

于 2012-11-16T09:34:42.383 回答