RFC: include: Add '_ONCE' variants of DPRINTF, FIXME, WARN and ERR

Sven Baars sven.wine at gmail.com
Sun Jan 2 05:22:32 CST 2011


Hey all,

adding '_ONCE' variants of DPRINTF, FIXME, WARN and ERR is a topic that 
came up before on wine devel. The first version of the attached patch 
was submitted by Max TenEyck Woodbury, but was deferred until after wine 
1.2. I still thought it was a good idea to have the _ONCE variants, so I 
mailed Max, but he said he backed out after finding out it was not 
feasible to do it right. I fixed some errors in his patch, but as Max 
pointed out to me, for compilers that don't support variadic macros, 
it's not possible to create a scope block to declare the static variable 
in. This is because of the (void)wine_dbg_printf call at the end of the 
(non-variadic) __WINE_DPRINTF_ONCE macro. wine_dbg_printf is a variadic 
function, any code after that function call breaks the macro (so a 
';}while(0)' can't be added to close the scope). AFAIK, this is the 
reason why a do{...}while(0) loop can't be used as it's done in the others.

Now I was wondering if there is a solution to this, or if it's ok to 
implement the _ONCE variants with the current patch. Using the current 
patch would mean that with a compiler that doesn't support C99, you 
would still have you at lot of the FIXMEs/WARNs where you don't want 
them. This would not be a problem right after the implementation, but 
only after replacing constructions like

static int once;
if(!once++)
     FIXME()

with the corresponding _ONCE(). It wouldn't really break anything though.

Also, it'd probably be better to replace

#elif defined(__SUNPRO_C)

with something like

#elif __STDC_VERSION__ >= 199901L

because that's what you're actually looking for. This would mean that 
the non-variadic _ONCE implementation is less of a problem, because more 
compilers would use the variadic __WINE_DPRINTF_ONCE macro. The #ifdef 
__GNUC__ would still remain because of their own implementation of 
variadic macros (from before C99).

Have a happy new year!

Sven


---
  include/wine/debug.h |   44 +++++++++++++++++++++++++++++++++++++++++++-
  1 files changed, 43 insertions(+), 1 deletions(-)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-include-Add-_ONCE-variants-of-DPRINTF-FIXME-WARN-and.patch
Type: text/x-patch
Size: 5151 bytes
Desc: not available
URL: <http://www.winehq.org/pipermail/wine-devel/attachments/20110102/071ea678/attachment.bin>


More information about the wine-devel mailing list