3 ms·
Back in 2001, when VS6 couldn't even parse templates correctly, I was making games on Linux but wanted them to run on Windows and Mac too. I also wanted stack
by ggambetta 11y ago
Back in 2001, when VS6 couldn't even parse templates correctly, I was making games on Linux but wanted them to run on Windows and Mac too.
I also wanted stack traces in exceptions (or being able to get them at any time, really) and I wanted to make them encrypted, to avoid giving away the internal structure of our game and engine code.
The solution I came up with was to have a global array representing the stack trace, a macro that would create a small scoped object which pushed a new "stack trace" entry on creation and popped it on destruction, and a script that would add a call to this macro to the beginning of each method with any payload I wanted -usually the encrypted filename, line and signature of the method, but it was possible to append e.g. parameter values as well.
Since these strings were compile time constants, this whole thing was surprisingly cheap, and worked great for over a decade.
With C++ there always is a way :)