The most obvious approach would seem to be to give your own version of assert its own name, slightly different from assert()
. Then you can search the text, look at linker messages, etc., for the literal string "_assert" and you know you have a problem when you see it.
In my own code, I always use Assert()
, which expands to my own function that performs an assertion, or expands to ((void)0)
for the release build. The compiler will turn the ((void)0)
expression into nothing, but it still counts as an expression. Thus
Assert(3 == x);
will turn into
((void)0);
and the semicolon has a place to go.
By the way, I once worked on a GUI application where the assert was a special GUI modal popup dialog. You had three choices: Ignore, Ignore forever, or Break. Ignore would ignore the assert and keep running. Ignore forever would set a flag, and until you restarted the program in the debugger, that assert would not fire anymore. Break would allow the assert to break into the debugger.
I don't remember how they guaranteed that each assert had its own flag. Maybe when you wrote the Assert() call you had to specify a unique integer? It would be nice if it was more automatic than that. I'm pretty sure that the actual implmentation was a bit vector, and it would set the bit when you chose ignore forever.