trapping-floating-point-exceptions

Programming applications for making music on Linux.

Moderators: MattKingUSA, khz

Post Reply
tramp
Established Member
Posts: 2335
Joined: Mon Jul 01, 2013 8:13 am
Has thanked: 9 times
Been thanked: 454 times

trapping-floating-point-exceptions

Post by tramp »

Recently I've found a nice way to trapping SIGFPE (floating-point-exceptions) when write DSP algorithm. It's fenv.h which is a standard header and provide the function feenableexcept().
Setting it up with
feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW);
when running a gdb session, the program will stop at the line were the error occur and you get the exact line number with the call in question. This make it a lot easier to find the culprit in the source, special when you work on bigger programs.
On the road again.
Post Reply