|
Boost : |
From: Darin Adler (darin_at_[hidden])
Date: 2001-09-23 11:04:07
on 9/23/01 8:01 AM, Howard Hinnant at hinnant_at_[hidden] wrote:
> There's a technique for converting macros into inlines that I came up
> with and used in the Metrowerks C++ lib to deal with this problem. If
> someone wants to apply this technique in boost, I have no objections:
>
> #ifdef isspace
> inline int __isspace_imp(int x) {return isspace(x);}
> #undef isspace
> inline int isspace(int x) {return __isspace_imp(x);}
> #endif
>
> If isspace is a macro, then create a helper inline that does nothing but
> call the isspace macro. Then #undef isspace. Finally create an isspace
> inline that calls the helper inline.
I used an even simpler workaround:
inline int (isspace)(int x) {return isspace(x);}
#undef isspace
The parentheses around the name of the function are legal, and they prevent
the isspace() macro from expanding. I do put this in the std namespace.
-- Darin
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk