Is there a way to control how messages from failed assertions (assert.h
) are displayed?
On OS X they are written to stderr. On Windows I noticed that a dialog box comes up and displays the message. Can I use my own custom display or logging method?
I expect the answer to be platform dependent, so this question is specifically for OS X when using the system compiler.
Notes:
It is not sufficient for my purposes to redirect the output to a file. I would like to provide my own function to display or log the message.
I cannot simply redefine the
assert
macro because every subsequent#include <assert.h>
restores the original behaviour, per the standard.I need this for dealing with assertion failures from libraries that are not my own. For my own code I can always use my own special assert macro which is named something else than
assert
.