1

Is it possible to document a typedef that depending on a preprocessor define has different types in a way that displays both alternatives in html output using Doxygen?

The code I'd like to document:

/**
 * \file
 */

#ifdef _WIN32
/**
 * Documentation for Windows goes here...
 */
typedef wchar_t MyChar;
#else
/**
 * Documentation for Non-Windows goes here...
 */
typedef char MyChar;
#endif

I've tested several preprocessor-related settings, but I could only change the typedef displayed in the html output or merge the documentation. I even managed to have one typedef show up in the overview section of the file and the other one in the detailed description. However I wasn't able to make both alternatives show up simultaneously.

I managed to produce the following 2 alternatives:

----------------------------------------------
typedef wchar_t   | MyChar   | ....
----------------------------------------------
----------------------------------------------
typedef char      | MyChar   | ....
----------------------------------------------

But not something like this

----------------------------------------------
typedef wchar_t   | MyChar   | ....
----------------------------------------------
typedef char      | MyChar   | ....
----------------------------------------------

Note: I don't mind modifying the source code as long as

  • In the documentation both alternatives are reasonably documented in the Doxygen output; both wchar_t and char need to be displayed in the typedef ... part
  • The compiler produces the same result for the modified and the current version of the file
  • IDE autocompletion, in particular Visual Studio 2019's IntelliSense, still displays reasonable tooltips (optional)
fabian
  • 80,457
  • 12
  • 86
  • 114

1 Answers1

0

Not really an answer, just more a question / suggestion whether the following would be acceptable:

/** \cond */
#ifdef _WIN32
#define used_type wchar_t
#else
#define used_type char
#endif
/** \endcond */
/**
 * Documentation for Windows goes here...
 *
 * Documentation for Non-Windows goes here...
 */
typedef used_type MyChar;

Resulting in:

enter image description here

albert
  • 8,285
  • 3
  • 19
  • 32
  • Thank you for the answer. This may be one step to a possible solution. I'd need to add documentation to the macro mentioning both alternatives. However a solution where I can see the types in the summary (excluding the "brief" part) would be preferrable. – fabian Oct 15 '21 at 17:35