#include <stdio.h>
#include <stdlib.h>
#define RTASSERT(expr,msg){if(!(expr)){fprintf(stderr,"runtime assertion error:\n\tfile: %s\n\tline: %d\n\tfunction: %s\n\texpression: %s\n\tmessage: %s\n",__FILE__,__LINE__,__FUNCTION__,(#expr),(msg));exit(EXIT_FAILURE);}}
int main( int argc, char *argv[] ) {
RTASSERT( 2 + 2 == 5, "lol 2 + 2 != 5" );
return EXIT_SUCCESS;
}
runtime assertion error:
file: foo.c
line: 7
function: main
expression: 2 + 2 == 5
message: lol 2 + 2 != 5
is there something in the standard i should be using instead or is there a better way to do this?