Open knrafto opened 4 years ago
Would a valid macro expansion be:
if (!condition) { fprintf(stderr, _format, ...); fflush(stderr); assert(false); }
s/fprintf/dbgprintf, so it shows the component info and the original file/line. But it would be nice to flag it as "this is an assertion failure!" instead of being a normal log line. If we have that, then we can use abort() instead of assert(false)
I've noticed if I do a
dbgprintf
and then anassert(false)
, sometimes the debug message isn't printed before the program dies. I'm not sure why. Compiler optimization? Stream not getting flushed?I would appreciate it if there was a function like
where I could add a nice debugging message for why the assertion failed (similar to LOG(FATAL) or CHECK() at Google), and also log the component info like dbgprintf() does.