xref: /haiku/headers/posix/assert.h (revision 5e96d7d537fbec23bad4ae9b4c8e7b02e769f0c6)
1 /*
2  * Copyright 2004-2012 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 	__attribute__ ((noreturn));
21 
22 extern void __assert_perror_fail(int error, const char *file,
23 				unsigned int line, const char *function)
24 	__attribute__ ((noreturn));
25 
26 #ifdef __cplusplus
27 }
28 #endif
29 
30 #define assert(assertion) \
31 	((assertion) ? (void)0 : __assert_fail(#assertion, __FILE__, __LINE__, __PRETTY_FUNCTION__))
32 
33 #else	/* NDEBUG */
34 #	define assert(condition) ((void)0)
35 #endif
36 
37 #endif	/* _ASSERT_H_ */
38