delphi - EOverflow Exception and +INF in COM DLL -


in delphi seattle, have calculation function of following construct:

try   result := ..... // calculation except   // handle (overflow) exception end; 

calling function exe, works expected , overflow exception trapped , handled. however, calling function com dll, exception not trapped. debugging, figured out result becomes +inf , eoverflow exception not raised (which has knock-on effect further in code).

after experimentation figured out changing function following work com dll:

try   result := ..... // calculation   if result = infinity     raise eoverflow.create('forced overflow'); except   // handle (overflow) exception end; 

i suppose wrap 'if result = ... ' code in {$ifdef myflag} block compiles com dll (which fine quick-fix), wondering if there's more elegant solution.

doing research on web, have come across suggestion use setexceptionmask or $finitefloat compiler directive. setexceptionmask seems rather tricky (side effects?) , $finitefloat seems have no effect, more or less expected since on supposed default...

moreover, suggestions found older (even .net) versions of delphi, makes me bit weary apply it.

any thoughts or suggestions? in advance considering!


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -