assert_default_params.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
void
assert_func ( int
cond , const
char
msg
) { if (! cond
) { fprintf ( stderr , "assert failed: %s\n" , msg
); abort
();
}
}
#define
assert_helper ( x , y
, ...) assert_func(x, y) #define
assert ( x
, ...) assert_helper((x), ## VA_ARGS, #x) int
main ( int
argc , char
argv
) { assert ( argc
0
); assert ( argv [ 0 ] !=
0 ,
"argv[0] cannot be null"
);
}