doxygen 宏定義/宏編譯/條件編譯/預處理/預編譯 不處理、忽略條件、分析所有條件、滿足所有條件的方法

hrdom發表於2024-03-05
#if defined(ENABLE_DEVICE_CRITICAL_LOCK_UNLOCK_CMDS)
#ifdef ENABLE_BOOT_CMD
doxygen 宏定義/宏編譯/條件編譯/預處理/預編譯 不處理、忽略條件、分析所有條件、滿足所有條件的方法
這裡把ENABLE_PREPROCESSING取消選中

MACRO_EXPANSION

注意,doxygen現在將展開所有宏定義(如果需要的話遞迴地)。這往往太多了。因此,doxygen還允許您只擴充套件那些顯式指定的定義。為此,您必須將EXPAND_ONLY_PREDEF標籤設定為YES,並在PREDEFINED或EXPAND_AS_DEFINED標籤之後指定宏定義。

示例

/*! A reference to an IID */
#ifdef __cplusplus
#define REFIID const IID &
#else
#define REFIID const IID *
#endif


/*! The IUnknown interface */
DECLARE_INTERFACE(IUnknown)
{
STDMETHOD(HRESULT,QueryInterface) (THIS_ REFIID iid, void **ppv) PURE;
STDMETHOD(ULONG,AddRef) (THIS) PURE;
STDMETHOD(ULONG,Release) (THIS) PURE;
};


ENABLE_PREPROCESSING = YES
MACRO_EXPANSION = YES
EXPAND_ONLY_PREDEF = YES
PREDEFINED = "DECLARE_INTERFACE(name)=class name" \
"STDMETHOD(result,name)=virtual result name" \
"PURE= = 0" \
THIS_= \
THIS= \
__cplusplus

/*! A reference to an IID */
#define REFIID

/*! The IUnknown interface */
class IUnknown
{
virtual HRESULT QueryInterface ( REFIID iid, void **ppv) = 0;
virtual ULONG AddRef () = 0;
virtual ULONG Release () = 0;
};

參考
https://stackoverflow.com/questions/41196305/doxygen-document-all-conditional-defines
https://stackoverflow.com/questions/26043007/make-doxygen-document-the-ifdef-parts-too
https://stackoverflow.com/questions/5370369/doxygen-expand-macros-but-ignore-if
https://www.doxygen.nl/manual/preprocessing.html
PREDEFINED預定義的
EXPAND_AS_DEFINED要展開的宏

相關文章