xref: /haiku/headers/posix/assert.h (revision 8a990d5228b2d1099e3062180532ba709dfeef6d)
1 /*
2  * Copyright 2004-2010 Haiku Inc. All Rights Reserved.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef _ASSERT_H_
6 #define _ASSERT_H_
7 
8 
9 #undef assert
10 
11 #ifndef NDEBUG
12 	/* defining NDEBUG disables assert() functionality */
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 
18 extern void __assert_fail(const char *assertion, const char *file,
19 				unsigned int line, const char *function);
20 
21 extern void __assert_perror_fail(int error, const char *file,
22 				unsigned int line, const char *function);
23 
24 #ifdef __cplusplus
25 }
26 #endif
27 
28 #define assert(assertion) \
29 	((assertion) ? (void)0 : __assert_fail(#assertion, __FILE__, __LINE__, __PRETTY_FUNCTION__))
30 
31 #else	/* NDEBUG */
32 #	define assert(condition) ((void)0)
33 #endif
34 
35 #endif	/* _ASSERT_H_ */
36