I am compiling a MinGW program on Windows (in this case Windows 8.1) and I want to have signals for floating-point errors to be thrown. For some reason I have to use _controlfp_s
to enable these signals (None of the other signals require something like this, only floating point errors for some reason), combined with a call to SetUnhandledExceptionFilter
to get the exceptions so I can do things like get a stack trace etc... On the version of Windows that I am compiling/testing on, this isn't a problem. However, apparently older versions of msvcrt.dll
(such as the ones on Windows XP for example) do not contain an entry for _controlfp_s
, and thus cause the program to crash because it can't find this function in the CRT library.
My objective is to make my program "cross-platform" such that, in the newer versions of windows that I am testing on: _controlfp_s is called correctly and I get signals for floating-point errors, and on older versions like XP, nothing gets called and we go on our merry way without EXCEPTION_FLT_INVALID_OPERATION or EXCEPTION_FLT_DIVIDE_BY_ZERO exceptions getting thrown.. :')
Is this even possible? Is there some other way of doing this that doesn't involve not being able to throw/catch floating-point exceptions?
I've checked SO & Google. MSDN is completely worthless.