Justus Winter, le Tue 28 Oct 2014 23:18:37 +0100, a écrit :
> * libshouldbeinlibc/assert-backtrace.h: New file.
> * libshouldbeinlibc/Makefile (installhdrs): Add assert-backtrace.h.
Yes, looks like a good place. I've always wondered with glibc doesn't
provide a backtraced assertion like most modern programming environment
do :)
> +#ifndef NDEBUG
This will need an #else after the suggestion I make below.
> +/* This prints an "Assertion failed" message and aborts. */
> +static void __assert_fail_backtrace (const char *__assertion,
This should have an inline qualifier, shouldn't it?
> + const char *__file,
> + unsigned int __line,
> + const char *__function)
> + __attribute__ ((noreturn, unused));
> +
> +#undef assert
> +#define assert(expr) \
I'd say rather define another macro, assert_backtrace. I prefer
to s/assert/assert_backtrace/ in the whole tree than undefine an
other-lib-provided macro :)
> +static inline void
> +__assert_fail_backtrace (const char *__assertion, const char *__file,
> + unsigned int __line, const char *__function)
> +{
> +#define SIZE 128
> +#define SKIP 1
Way better use const int size = 128, skip = 1 than risking undefining
something from the includer :)
Samuel