Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Doxygen documenting commented #define

I'm new to Doxygen and recently run into a problem which I could not solve. I have this piece of documented code:

/*!
    \def nAsserts
    Uncomment that line so that all asserts would be removed
*/
//#define nAsserts

and it's supposed to tell the user to uncomment that line when they wish to remove all asserts but doxygen is returning me a warning:

warning: documentation for unknown define nAsserts found

I think the problem is that doxygen ignores all commented codes so is that any way to fix this or work around it?

like image 424
Cheng Lai Avatar asked Apr 29 '26 04:04

Cheng Lai


1 Answers

Not sure if it is a best option, but you can use the approach below.

Modify configuration file to include PREDEFINED parameter:

ENABLE_PREPROCESSING = YES
MACRO_EXPANSION      = YES
EXPAND_ONLY_PREDEF   = YES
PREDEFINED           = "DOXYGEN=1"

In your code, do the following:

#if DOXYGEN
#define nAsserts
#endif

Doxygen follows own preprocessor and can conditionally include/exclude source module sections.

like image 57
Valeri Atamaniouk Avatar answered May 01 '26 20:05

Valeri Atamaniouk



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!