assert.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. // Copyright 2013 Dolphin Emulator Project / 2014 Citra Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include "common/common_funcs.h"
  6. // TODO (yuriks) allow synchronous logging so we don't need printf
  7. #define ASSERT(_a_) \
  8. do if (!(_a_)) {\
  9. fprintf(stderr, "Assertion Failed!\n\n Line: %d\n File: %s\n Time: %s\n", \
  10. __LINE__, __FILE__, __TIME__); \
  11. Crash(); \
  12. } while (0)
  13. #define ASSERT_MSG(_a_, ...) \
  14. do if (!(_a_)) {\
  15. fprintf(stderr, "Assertion Failed!\n\n Line: %d\n File: %s\n Time: %s\n", \
  16. __LINE__, __FILE__, __TIME__); \
  17. fprintf(stderr, __VA_ARGS__); \
  18. fprintf(stderr, "\n"); \
  19. Crash(); \
  20. } while (0)
  21. #define UNREACHABLE() ASSERT_MSG(false, "Unreachable code!")
  22. #ifdef _DEBUG
  23. #define DEBUG_ASSERT(_a_) ASSERT(_a_)
  24. #define DEBUG_ASSERT_MSG(_a_, ...) ASSERT_MSG(_a_, __VA_ARGS__)
  25. #else // not debug
  26. #define DEBUG_ASSERT(_a_)
  27. #define DEBUG_ASSERT_MSG(_a_, _desc_, ...)
  28. #endif
  29. #define UNIMPLEMENTED() DEBUG_ASSERT_MSG(false, "Unimplemented code!")