Dan Kegel wrote:
How about this:
#define WINE_ONCE(x) { static int wine_once_var##__LINE__; if (!wine_once_var##__LINE__++) { x; }}
Example use:
- static int once;
- if (!once++) FIXME_(keyboard)("(%p,%d,0x%08x,%X):
stub\n",hwnd,id,modifiers,vk);
- WINE_ONCE(FIXME_(keyboard)("(%p,%d,0x%08x,%X):
stub\n",hwnd,id,modifiers,vk));
Hmm... Yeah... That's also a solution of course. Though it's not as elegant :P
But I'm not sure if the ##__LINE__ is really necessary. And the ++ might cause an overflow. So this might be better
#define WINE_ONCE(x) { \ static int wine_once_var; \ if (!wine_once_var) { \ wine_once_var = 1; \ x; }}
and possibly
#ifdef __WINESRC__ #define ONCE(x) WINE_ONCE(x) #endif
And then a char can be used to save space (if that's of any concern). And volatile in case the compiler does some weird things (but probably won't).
Thanks for the idea Dan.
Sven