string
Last change
on this file since 8243cf9 was
a772d8ab,
checked in by Thierry Delisle <tdelisle@…>, 8 years ago
|
basic commit + some work on assertion to make them match normal assertions
|
-
Property mode set to
100644
|
File size:
698 bytes
|
Line | |
---|
1 | #pragma once |
---|
2 | |
---|
3 | #if NDEBUG |
---|
4 | |
---|
5 | #define assert(x) |
---|
6 | #define assertf(x, ...) |
---|
7 | |
---|
8 | #else |
---|
9 | |
---|
10 | #ifdef __cforall |
---|
11 | extern "C" { |
---|
12 | #endif |
---|
13 | #include <stdlib.h> |
---|
14 | #include <stdio.h> |
---|
15 | #ifdef USE_BSD_LIB |
---|
16 | #include <bsd/stdlib.h> |
---|
17 | #endif |
---|
18 | #ifdef __cforall |
---|
19 | } |
---|
20 | #endif |
---|
21 | |
---|
22 | #ifdef USE_BSD_LIB |
---|
23 | #define OUT_TXT "%s: %s:%i: %s: Assertion \'%s\' failed.\n", getprogname() |
---|
24 | #else |
---|
25 | #define OUT_TXT "%s:%i: %s: Assertion \'%s\' failed.\n" |
---|
26 | #endif |
---|
27 | |
---|
28 | #define assert(x) do {\ |
---|
29 | if(!(x)) {\ |
---|
30 | printf(OUT_TXT, __FILE__, __LINE__, __PRETTY_FUNCTION__, #x);\ |
---|
31 | abort();\ |
---|
32 | }}while(1 == 2)\ |
---|
33 | |
---|
34 | |
---|
35 | #define assertf(x, ...) do {\ |
---|
36 | if(!(x)) {\ |
---|
37 | printf(OUT_TXT, __FILE__, __LINE__, __PRETTY_FUNCTION__, #x);\ |
---|
38 | printf(__VA_ARGS__);\ |
---|
39 | abort();\ |
---|
40 | }}while(1 == 2)\ |
---|
41 | |
---|
42 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.