assert.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. assert.h
  3. */
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. #include "_ansi.h"
  8. #undef assert
  9. #ifdef NDEBUG /* required by ANSI standard */
  10. # define assert(__e) ((void)0)
  11. #else
  12. # define assert(__e) ((__e) ? (void)0 : _assert ())
  13. # ifndef __ASSERT_FUNC
  14. /* Use g++'s demangled names in C++. */
  15. # if defined __cplusplus && defined __GNUC__
  16. # define __ASSERT_FUNC __PRETTY_FUNCTION__
  17. /* C99 requires the use of __func__. */
  18. # elif __STDC_VERSION__ >= 199901L
  19. # define __ASSERT_FUNC __func__
  20. /* Older versions of gcc don't have __func__ but can use __FUNCTION__. */
  21. # elif __GNUC__ >= 2
  22. # define __ASSERT_FUNC __FUNCTION__
  23. /* failed to detect __func__ support. */
  24. # else
  25. # define __ASSERT_FUNC ((char *) 0)
  26. # endif
  27. # endif /* !__ASSERT_FUNC */
  28. #endif /* !NDEBUG */
  29. void _assert (void) _ATTRIBUTE ((__noreturn__));
  30. void __assert (const char *, int, const char *)
  31. _ATTRIBUTE ((__noreturn__));
  32. void __assert_func (const char *, int, const char *, const char *)
  33. _ATTRIBUTE ((__noreturn__));
  34. #if __STDC_VERSION__ >= 201112L && !defined __cplusplus
  35. # define static_assert _Static_assert
  36. #endif
  37. #ifdef __cplusplus
  38. }
  39. #endif