assert.h 570 B

1234567891011121314151617181920212223242526
  1. /*
  2. * Copyright (c) mlibc & plct lab
  3. *
  4. * SPDX-License-Identifier: MIT
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2023/06/16 bernard the first verison
  9. */
  10. #ifndef MLIBC_ASSERT_H__
  11. #define MLIBC_ASSERT_H__
  12. #ifdef NDEBUG
  13. #define assert(expr)((void) 0)
  14. #else
  15. void __assert_fail (const char* expr, const char* file, int line);
  16. void __assert_func(const char *file, int line, const char *func, const char *failedexpr);
  17. #define assert(expr) \
  18. if (!(expr)) \
  19. __assert_fail(#expr, __FILE__, __LINE__)
  20. #endif
  21. #endif /*MLIBC_ASSERT_H__*/