Rev 4921 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4349 | Serge | 1 | /* |
2 | assert.h |
||
3 | */ |
||
4 | |||
4930 | Serge | 5 | #ifndef __ASSERT_H__ |
6 | #define __ASSERT_H__ |
||
7 | |||
4349 | Serge | 8 | #ifdef __cplusplus |
9 | extern "C" { |
||
10 | #endif |
||
11 | |||
12 | #include "_ansi.h" |
||
13 | |||
14 | #undef assert |
||
15 | |||
16 | #ifdef NDEBUG /* required by ANSI standard */ |
||
17 | # define assert(__e) ((void)0) |
||
18 | #else |
||
19 | # define assert(__e) ((__e) ? (void)0 : __assert_func (__FILE__, __LINE__, \ |
||
20 | __ASSERT_FUNC, #__e)) |
||
21 | |||
22 | # ifndef __ASSERT_FUNC |
||
23 | /* Use g++'s demangled names in C++. */ |
||
24 | # if defined __cplusplus && defined __GNUC__ |
||
25 | # define __ASSERT_FUNC __PRETTY_FUNCTION__ |
||
26 | |||
27 | /* C99 requires the use of __func__. */ |
||
28 | # elif __STDC_VERSION__ >= 199901L |
||
29 | # define __ASSERT_FUNC __func__ |
||
30 | |||
31 | /* Older versions of gcc don't have __func__ but can use __FUNCTION__. */ |
||
32 | # elif __GNUC__ >= 2 |
||
33 | # define __ASSERT_FUNC __FUNCTION__ |
||
34 | |||
35 | /* failed to detect __func__ support. */ |
||
36 | # else |
||
37 | # define __ASSERT_FUNC ((char *) 0) |
||
38 | # endif |
||
39 | # endif /* !__ASSERT_FUNC */ |
||
40 | #endif /* !NDEBUG */ |
||
41 | |||
42 | void _EXFUN(__assert, (const char *, int, const char *) |
||
43 | _ATTRIBUTE ((__noreturn__))); |
||
44 | void _EXFUN(__assert_func, (const char *, int, const char *, const char *) |
||
45 | _ATTRIBUTE ((__noreturn__))); |
||
46 | |||
4921 | Serge | 47 | #if __STDC_VERSION__ >= 201112L && !defined __cplusplus |
48 | # define static_assert _Static_assert |
||
49 | #endif |
||
50 | |||
4349 | Serge | 51 | #ifdef __cplusplus |
52 | } |
||
53 | #endif |
||
4930 | Serge | 54 | |
55 | #endif /* __ASSERT_H__ */ |