RE: [GD-Windows] variadic macros
Brought to you by:
vexxed72
From: Paul B. <pa...@wi...> - 2004-12-21 10:40:11
|
> -----Original Message----- > From: gam...@li...=20 > [mailto:gam...@li...] On=20 > Behalf Of Brett Bibby > Sent: Tuesday, December 21, 2004 2:42 AM > To: gam...@li... > Subject: Re: [GD-Windows] variadic macros >=20 > > Paul Bleisch wrote: > > Depending on what you're after, you might find that the __noop=20 > > intrinsic will help you out. > > >=20 > That's new, thanks. I don't think I can use it still though=20 > as I need to insert some parameters before calling the debug function. >=20 > This is what we have on other platforms: >=20 > #define MPE_SHELL_ERROR_LOG(...) \ > MpiShellLogTextAdd(__FILE__, \ > (MpeChar *)__func__, \ > __LINE__, \ > MPE_SHELL_LOG_FLAG_ERROR, \ > __VA_ARGS__) >=20 >=20 > I want to insert the file, func and line number. (BTW, does=20 > windows allow __func__ ?) >=20 > Thanks again, > Brett __func__ is not, but __FUNCTION__ is available (which I think is equivalent). A potential workaround for your varargs macros is to do something like: #ifdef _DEBUG void _SetDebugInfo(MpeChar* file, MpeChar* func, int line, unsigned flags); void _DebugPrint(char* fmt, ...); #define MPE_SHELL_ERROR_LOG _SetDebugInfo(__FILE__, __FUNCTION__, __LINE__, MPE_SHELL_LOG_FLAG_ERROR), _DebugPrint #else #define MPE_SHELL_ERROR_LOG __noop #endif this is not threadsafe and not a 1:1 replacement for your current code, so beware. Paul |