doxygenundef

Good way to document #undef in doxygen


I currently have a couple of #define in c files that turn off some functionality to hardware for testing. However, I want to document them with doxygen when they are undefined as well.

For example:

This works fine:

/// \def SIMULATE_SOME_HW_INTERFACE
/// Define this when you want to simulate HW interface.
#define SIMULATE_SOME_HW_INTERFACE

When you change the #define to #undef, you get a warning in doxygen, and it doesn't show up in the doxygen generated output. I want to document this #define wether it's defined or undefined.

How can I force doxygen to document a #undef???


Solution

  • Define them in a header file that is only included by Doxygen (put in a separate directory tree from the main source).

    Guard this header file by wrapping it with a define that you only define in the Doxygen setup, eg:

    #ifdef ONLY_FOR_DOXYGEN
    
    /// \def SIMULATE_SOME_HW_INTERFACE
    /// Define this when you want to simulate HW interface.
    #define SIMULATE_SOME_HW_INTERFACE
    
    #endif
    

    I have used this to also conditionally include lightweight class definitions for things like MFC base classes so they appear as bases for the class hierarchy without having to parse all of MFC.