Re: [Doxygen-develop] Doxygen messes up with PRINTF_ATTRIBUTES macro
Brought to you by:
dimitri
From: Dimitri V. H. <do...@gm...> - 2010-05-07 20:19:23
|
Hi Andreas, On 7 mei 2010, at 21:37, Andreas Schneider wrote: > On Friday 07 May 2010 20:48:26 you wrote: >> Hi Andreas, >> >> On 7 mei 2010, at 10:32, Andreas Schneider wrote: >>> Hi, >>> >>> I've created API documentation for talloc.samba.org. Doxygen has a >>> problem >>> correctly creating documentation for a function which has a printf >>> attribute >>> checking at the end using a macro. >>> >>> #define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (__printf__, >>> a1, a2))) >>> #else >>> #define PRINTF_ATTRIBUTE(a1, a2) >>> #endif >>> #endif >>> >>> void *talloc_init(const char *fmt, ...) PRINTF_ATTRIBUTE(1,2); >>> >>> It adds the return value of this function to the output of the next. >>> >>> void * talloc_init (const char *fmt,...) PRINTF_ATTRIBUTE(1 >>> >>> Create a new top level talloc context. >>> >>> void *int talloc_free (void *ptr) >>> >>> Free a chunk of talloc memory. >>> >>> See http://talloc.samba.org/talloc/doc/html/group__talloc.html >>> >>> I can work around the problem using #ifdef DOXYGEN but I think it >>> should be >>> fixed in doxygen. >> >> You can configure doxygen's preprocessor such that no #ifdef's are >> needed to >> parse the code properly. > > Do you have an example how to do it? > Given this: -------------------------------------------------------------- #ifdef SOMETHING #define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (__printf__, a1, a2))) #else #define PRINTF_ATTRIBUTE(a1, a2) #endif /// Blah void *talloc_init(const char *fmt, ...) PRINTF_ATTRIBUTE(1,2); -------------------------------------------------------------- This should work: ENABLE_PREPROCESSING = YES MACRO_EXPANSION = YES EXPAND_ONLY_PREDEF = NO PREDEFINED = But you can also use this: ENABLE_PREPROCESSING = YES MACRO_EXPANSION = YES EXPAND_ONLY_PREDEF = YES PREDEFINED = PRINTF_ATTRIBUTE(x,y)= See http://www.stack.nl/~dimitri/doxygen/preprocessing.html for more info. Use doxygen with the -d Preprocessor option to see the result after preprocessing. Regards, Dimitri |