Sure, preprocessor is good for compile-time detection.
I’m speaking of runtime detection.
I’m looking for a cross platform solution of “IsDebuggerPresent” under Win32.
I don’t like having 2 paths for the code (one with #define DEBUG and the other without), as 100% sure a fatal bug will appear in the #ifndef DEBUG part.
On the other side, it’s just the splash screen…
Under linux, I know about the “get parent pid of our pid, and if it is gdb, then we are under a debugger” trick, but I don’t know of any trick like this in MacOSX
Another solution, is to do something like :
bool debugHere = false;
asm int 3;
debugHere = true;
But it’s very x86 specific (due to asm part).
I don’t know of any other cross platform way, and I was wondering if any of you know about.