]>
Commit | Line | Data |
---|---|---|
64bc6412 EA |
1 | #ifndef __ASSERT_H |
2 | #define __ASSERT_H | |
3 | #include <features.h> | |
4 | ||
5 | /* If NDEBUG is defined, do nothing. | |
6 | If not, and EXPRESSION is zero, print an error message and abort. */ | |
7 | ||
8 | #ifdef NDEBUG | |
9 | ||
10 | #define assert(expr) ((void) 0) | |
11 | ||
12 | #else /* Not NDEBUG. */ | |
13 | ||
448e40e8 | 14 | extern void __assert __P((const char *, const char *, int, const char *)); |
64bc6412 EA |
15 | |
16 | #define assert(expr) \ | |
17 | ((void) ((expr) || \ | |
18 | (__assert (__STRING(expr), \ | |
448e40e8 EA |
19 | __FILE__, __LINE__, __ASSERT_FUNCTION), 0))) |
20 | ||
21 | ||
22 | /* Version 2.4 and later of GCC define a magical variable `__PRETTY_FUNCTION__' | |
23 | which contains the name of the function currently being defined. | |
24 | # define __ASSERT_FUNCTION __PRETTY_FUNCTION__ | |
25 | This is broken in G++ before version 2.6. | |
26 | C9x has a similar variable called __func__, but prefer the GCC one since | |
27 | it demangles C++ function names. */ | |
28 | # ifdef __GNUC__ | |
29 | # if __GNUC__ > 2 || (__GNUC__ == 2 \ | |
30 | && __GNUC_MINOR__ >= (defined __cplusplus ? 6 : 4)) | |
31 | # define __ASSERT_FUNCTION __PRETTY_FUNCTION__ | |
32 | # else | |
33 | # define __ASSERT_FUNCTION ((__const char *) 0) | |
34 | # endif | |
35 | # else | |
36 | # if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L | |
37 | # define __ASSERT_FUNCTION __func__ | |
38 | # else | |
39 | # define __ASSERT_FUNCTION ((__const char *) 0) | |
40 | # endif | |
41 | # endif | |
42 | ||
64bc6412 EA |
43 | |
44 | #endif /* NDEBUG. */ | |
45 | ||
46 | #endif /* __ASSERT_H */ |