I'm looking for advice/opinions/wisdom on wether or not it makes sense to use the somewhat obscure C feature setjmp/longjmp in a commercial product. I currently use it to jump out of a failed assert and back to the beginning of the main loop where it then makes a graceful exit after displaying an error message.
It's a game, so yeah it's performance critical but setjmp is only called once a frame.
I assume you mean print the error through a windows alert box or something and not within the actual program itself. I just think that rendering the error message within the game itself is a lot more elegant and less jarring aesthetically than closing out the game window and bringing up a windows notification box with an annoying alert sound.
Very interesting. Is there any reason to favor this approach versus setjmp/longjmp (which seems to me simpler). And I assume this wouldn't work or would be much harder to pull off on OS X because of the timer callback stuff, as I also need to maintain a working mac build.
Not many people know about setjmp/longjmp, its a bit obscure feature. Also it does not play well across API boundaries or different languages, like C++. longjmp will skip stack unwinding - that means there will be no destructors called.