开发者

Documenting macros (with doxygen) for a member of a struct

开发者 https://www.devze.com 2023-01-04 15:12 出处:网络
I prefer to define certain macros inside of my struct definitions, so it\'s easy to see possible values for a given member.For example:

I prefer to define certain macros inside of my struct definitions, so it's easy to see possible values for a given member. For example:

typedef struct foo_t {
    uint16_t flags;
        #define FOO_FLAG_BELL       0x0001
        #define FOO_FLAG_BOOK       0x0002
        #define FOO_FLAG_CANDLE     0x0004
        #define FOO_FLAG_LANTERN    0x0008
}

Doxygen wants to list those macros at the top, with all of the other macros. I've make use of the grouping tags (//@{ and //@}) to group these macros together, and named the group with foo_t.flags, but I'd li开发者_高级运维ke to find a way to more-closely associate the values with the structure. Should I use \link and \endlink to somehow link to that group name?


Use enums.

typedef struct foo_t {
  enum flag_define { 
    FOO_FLAG_BELL    =  0x0001,    /**< The flag for the bell or whatever. */
    FOO_FLAG_BOOK    =  0x0002,
    FOO_FLAG_CANDLE  =  0x0004,
    FOO_FLAG_LANTERN =  0x0008,
  } flags:16;                      /**< My flag thing */
}  foo_t;
0

精彩评论

暂无评论...
验证码 换一张
取 消