4 ms·
In C you have no exception handling. The closest you can get is seqfualts. With a segfault the debugger can give you a backtrace at almost the exact issue point
by Danieru 14y ago
In C you have no exception handling. The closest you can get is seqfualts. With a segfault the debugger can give you a backtrace at almost the exact issue point.
The easiest way to get segfaults is by dereferencing NULL. In C dereferencing NULL is invalid. Thus returning NULL on failure will result in something close to what raising an exception in other languages does.
In any language with real exception handling it makes much less sense, ignoring optimization.
- apaprocki 14y agoDereferencing NULL is undefined -- on AIX the page at 0x0 is readable.
- Daniel_Newby 14y agosetjmp and longjmp can be used for exception handling, if you want to lose your mind.
- tptacek 14y agoYou don't need to fault the program to take a stack trace.