1
0
mirror of https://frontier.innolan.net/github/AmigaExamples.git synced 2026-05-10 12:58:44 +00:00
Files
AmigaExamples/tools/external/shrinkler/assert.h
2016-03-15 16:25:03 +11:00

38 lines
921 B
C

// Copyright 1999-2015 Aske Simon Christensen. See LICENSE.txt for usage terms.
/*
An assert function which contains a breakpoint, for ease of debugging.
*/
#pragma once
void internal_error() {
fflush(stdout);
fprintf(stderr,
"\n\nShrinkler has encountered an internal error.\n"
"Please send a bug report to blueberry@loonies.dk,\n"
"providing the file you tried to compress.\n"
"\n"
"Thanks, and apologies for the inconvenience.\n\n");
fflush(stderr);
exit(1);
}
#ifndef NDEBUG
#include <stdio.h>
static void _assert_func(const char *file, int line, const char *exp) {
fflush(stdout);
fprintf(stderr, "\n\nassertion \"%s\" failed: file \"%s\", line %d\n", exp, file, line);
fflush(stderr);
#ifdef DEBUG
__asm volatile ("int3;");
#endif
internal_error();
}
#undef assert
#define assert(__e) ((__e) ? (void)0 : _assert_func (__FILE__, __LINE__, #__e))
#endif