assert.h
001:
002:
003:
004:
005:
006:
007:
008:
009:
010:
011:
012:
013:
014:
015:
016:
017:
018:
019:
020:
021:
022:
023:
024: #ifdef _ASSERT_H
025:
026: # undef _ASSERT_H
027: # undef assert
028: # undef __ASSERT_VOID_CAST
029:
030: # ifdef __USE_GNU
031: # undef assert_perror
032: # endif
033:
034: #endif
035:
036: #define _ASSERT_H 1
037: #include <features.h>
038:
039: #if defined __cplusplus && __GNUC_PREREQ (2,95)
040: # define __ASSERT_VOID_CAST static_cast<void>
041: #else
042: # define __ASSERT_VOID_CAST (void)
043: #endif
044:
045:
046:
047: BUG
048:
049:
050: #ifdef NDEBUG
051:
052: # define assert(expr) (__ASSERT_VOID_CAST (0))
053:
054:
055:
056: BUG
057:
058:
059:
060: # ifdef __USE_GNU
061: # define assert_perror(errnum) (__ASSERT_VOID_CAST (0))
062: # endif
063:
064: #else BUG
065:
066: #ifndef _ASSERT_H_DECLS
067: #define _ASSERT_H_DECLS
068: __BEGIN_DECLS
069:
070:
071: extern void __assert_fail (__const char *__assertion, __const char *__file,
072: unsigned int __line, __const char *__function)
073: __THROW __attribute__ ((__noreturn__));
074:
075:
076: extern void __assert_perror_fail (int __errnum, __const char *__file,
077: unsigned int __line,
078: __const char *__function)
079: __THROW __attribute__ ((__noreturn__));
080:
081:
082:
083:
084: extern void __assert (const char *__assertion, const char *__file, int __line)
085: __THROW __attribute__ ((__noreturn__));
086:
087:
088: __END_DECLS
089: #endif
090:
091: # define assert(expr) \
092: ((expr) \
093: ? __ASSERT_VOID_CAST (0) \
094: : __assert_fail (__STRING(expr), __FILE__, __LINE__, __ASSERT_FUNCTION))
095:
096: # ifdef __USE_GNU
097: # define assert_perror(errnum) \
098: (!(errnum) \
099: ? __ASSERT_VOID_CAST (0) \
100: : __assert_perror_fail ((errnum), __FILE__, __LINE__, __ASSERT_FUNCTION))
101: # endif
102:
103:
104:
105:
106:
107:
108: # if defined __cplusplus ? __GNUC_PREREQ (2, 6) : __GNUC_PREREQ (2, 4)
109: # define __ASSERT_FUNCTION __PRETTY_FUNCTION__
110: # else
111: # if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
112: # define __ASSERT_FUNCTION __func__
113: # else
114: # define __ASSERT_FUNCTION ((__const char *) 0)
115: # endif
116: # endif
117:
118: #endif BUG
119:
for client
18.223.125.219
© Andrew Scott 2006 -
2024,
All Rights Reserved