SetExceptionMask

From Lazarus wiki
Revision as of 13:58, 26 January 2022 by Alextp (talk | contribs) (Created page with "Q: I'm trying to "merge" an existing MS Visual C++ project with Lazarus by converting it to a DLL and then calling some of its entry points from the Lazarus app. Everything is...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Q: I'm trying to "merge" an existing MS Visual C++ project with Lazarus by converting it to a DLL and then calling some of its entry points from the Lazarus app. Everything is OK until some floating-point operation used and I get the exception 0xC00002B5.

A (forum member PascalDragon): C code doesn't usually expect the floating point exceptions that FPC enables. Use SetExceptionMask to disable the corresponding exceptions (especially overflow and underflow).

Set8087CW procedure only sets the control word for the x87 FPU, but in case of x86_64 Windows only SSE is used, thus the corresponding SSE exceptions wouldn't be disabled. And on ARM64 it doesn't exist at all. So the correct solution is SetExceptionMask (which handles both the x87 and SSE) and not Set8087CW directly.