threadpp_assert.h 673 B

123456789101112131415161718192021222324252627282930313233
  1. //
  2. // defines.h
  3. // threadpp
  4. //
  5. // Created by Melo Yao on 1/15/15.
  6. // Copyright (c) 2015 Melo Yao. All rights reserved.
  7. //
  8. #ifndef threadpp_assert_h
  9. #define threadpp_assert_h
  10. //forward VC++ DEBUG symbol.
  11. #if defined(_DEBUG) && !defined(DEBUG)
  12. #define DEBUG _DEBUG
  13. #endif
  14. #if DEBUG //assertions
  15. #ifdef __cplusplus
  16. #include <cassert>
  17. #include <cstdio>
  18. #else
  19. #include <assert.h>
  20. #include <stdio.h>
  21. #endif
  22. #define ASSERT0(__cond__) assert(__cond__)
  23. #define ASSERT(__cond__,__msg__,...) \
  24. do {if(!(__cond__)){printf(__msg__,__VA_ARGS__);printf("\n");assert(false);}}while(0)
  25. #else
  26. #define ASSERT0(__cond__)
  27. #define ASSERT(__cond__,__msg__,...)
  28. #endif //assertions
  29. #endif