| 1 | /** |
| 2 | * This file has no copyright assigned and is placed in the Public Domain. |
| 3 | * This file is part of the mingw-w64 runtime package. |
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. |
| 5 | */ |
| 6 | |
| 7 | /* According to C99 standard (section 7.2) the assert |
| 8 | macro shall be redefined each time assert.h gets |
| 9 | included depending on the status of NDEBUG macro. */ |
| 10 | #undef assert |
| 11 | |
| 12 | #ifndef __ASSERT_H_ |
| 13 | #define __ASSERT_H_ |
| 14 | |
| 15 | #include <crtdefs.h> |
| 16 | #ifdef __cplusplus |
| 17 | #include <stdlib.h> |
| 18 | #endif |
| 19 | |
| 20 | #ifdef __cplusplus |
| 21 | extern "C" { |
| 22 | #endif |
| 23 | |
| 24 | _CRTIMP void __cdecl _wassert(const wchar_t *_Message,const wchar_t *_File,unsigned _Line); |
| 25 | void __cdecl _assert (const char *_Message, const char *_File, unsigned _Line); |
| 26 | |
| 27 | #ifdef __cplusplus |
| 28 | } |
| 29 | #endif |
| 30 | |
| 31 | #endif /* !defined (__ASSERT_H_) */ |
| 32 | |
| 33 | #if (defined _ISOC11_SOURCE \ |
| 34 | || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 201112L)) \ |
| 35 | && !defined (__cplusplus) |
| 36 | /* Static assertion. Requires support in the compiler. */ |
| 37 | #undef static_assert |
| 38 | #define static_assert _Static_assert |
| 39 | #endif |
| 40 | |
| 41 | #ifdef NDEBUG |
| 42 | #define assert(_Expression) ((void)0) |
| 43 | #else /* !defined (NDEBUG) */ |
| 44 | #if defined(_UNICODE) || defined(UNICODE) |
| 45 | #define assert(_Expression) \ |
| 46 | (void) \ |
| 47 | ((!!(_Expression)) || \ |
| 48 | (_wassert(_CRT_WIDE(#_Expression),_CRT_WIDE(__FILE__),__LINE__),0)) |
| 49 | #else /* not unicode */ |
| 50 | #define assert(_Expression) \ |
| 51 | (void) \ |
| 52 | ((!!(_Expression)) || \ |
| 53 | (_assert(#_Expression,__FILE__,__LINE__),0)) |
| 54 | #endif /* _UNICODE||UNICODE */ |
| 55 | #endif /* !defined (NDEBUG) */ |