what's the purpose for FPU_CHECKER_ONCE(solved)
Added by sambsp over 4 years ago
in client code, there is "FPU_CHECKER_ONCE", I can find its definition in check_fpu.h, like this
// Use those Macros #if NL_CHECK_FPU_CONTROL_WORD #define FPU_CHECKER NLMISC::CFpuChecker __fpc__; #define FPU_CHECKER_ONCE { NLMISC::CFpuChecker __fpc__; } #else #define FPU_CHECKER #define FPU_CHECKER_ONCE #endif
What I want to know is the design purpose for this macor. thanks.
Replies (2)
RE: what's the purpose for FPU_CHECKER_ONCE - Added by rti over 4 years ago
Not sure if I really get your question right. But your are asking why there those two defines?
Well, as I think you have already seen, CFpuChecker
does some thinks in the ctor and in the dtor... It checks something.
CFpuChecker::CFpuChecker() { check(); } CFpuChecker::~CFpuChecker() { check(); }
So if you put FPU_CHECKER
in some context, e.g. a method or an if block, the first check is done at the point where you place the macro (inited by CFpuChecker's ctor), the second check (initiated by the dtor) is done when leaving the context (the method or if block).
If you put FPU_CHECKER_ONCE, then the dtor is called directly after the ctor, because the macro creates it's own context (by placing { and } ) which is immediately left.
I hope this was what you were asking for :)
(1-2/2)