|
Revision 106, 2.1 kB
(checked in by ng, 5 years ago)
|
mise a jour licence
|
| Line | |
|---|
| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
#ifndef ASSERT_H |
|---|
| 18 |
#define ASSERT_H |
|---|
| 19 |
|
|---|
| 20 |
#include <stdio.h> |
|---|
| 21 |
#include <stdlib.h> |
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
#define c_assert2(cond, str) __assert((cond), __LINE__, __FILE__, (str), #cond) |
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
#define c_assert(cond) c_assert2((cond), "assertion failed") |
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 |
#define c_warning2(cond, str) __warning((cond), __LINE__, __FILE__, (str), #cond) |
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
#define c_warning(cond) c_warning2((cond), "warning") |
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| 43 |
|
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 46 |
|
|---|
| 47 |
|
|---|
| 48 |
#ifndef DISABLE_ASSERT |
|---|
| 49 |
|
|---|
| 50 |
|
|---|
| 51 |
#define __assert(cond, line, file, str, cond_str) \ |
|---|
| 52 |
{ if(!cond) { fprintf(stderr, "assertion error on `" cond_str "' in " file " at line %d: %s\n", line, str); abort(); } } |
|---|
| 53 |
#define __warning(cond, line, file, str, cond_str) \ |
|---|
| 54 |
{ if(!cond) { fprintf(stderr, "warning on `" cond_str "' in " file " at line %d: %s\n", line, str) ; } } |
|---|
| 55 |
|
|---|
| 56 |
#else |
|---|
| 57 |
|
|---|
| 58 |
#define __assert(cond, line, file, str, cond_str) |
|---|
| 59 |
#define __warning(cond, line, file, str, cond_str) |
|---|
| 60 |
|
|---|
| 61 |
#endif |
|---|
| 62 |
|
|---|
| 63 |
|
|---|
| 64 |
#endif |
|---|