I’m trying to figure out a transparent solution for debug halts that repeatedly get hit in my game.
For a trivial example; say I have a halt in my renderer that tells me when I’m trying to use a NULL material. My renderer handles this fine but I still want to know what I’m doing wrong.
This halt will hit every frame now unless I manually disable it.
This is the code id like to turn into a macro (or something else thats as transparent as porssible)
#define HALT(errorMsg) printf(errorMsg);__asm { int 3 };
satic bool hitOnce = false;
if (!hitOnce)
{
hitOnce = true;
HALT("its all gone wrong!")
}
The idea i had, was to make a macro that created this code, with a unique bool variable each time. The problem Ive hit so far is that I cannot increment numbers to at compile time to generate unique static bools for each HALT_ONCE.
anything wrong with this?
Then you can just do this in your code:
The do/while creates its own scope which makes hitOnce only exist for a very short time. I think this will prevent it from conflicting with other hitOnce variables created by this macro.