common.hpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #ifndef _SCTL_COMMON_HPP_
  2. #define _SCTL_COMMON_HPP_
  3. // Define NULL
  4. #ifndef NULL
  5. #define NULL 0
  6. #endif
  7. #include <cstddef>
  8. #include <cstdint>
  9. namespace SCTL_NAMESPACE {
  10. typedef long Integer; // bounded numbers < 32k
  11. typedef int64_t Long; // problem size
  12. }
  13. #include <iostream>
  14. #define SCTL_WARN(msg) \
  15. do { \
  16. std::cerr << "\n\033[1;31mWarning:\033[0m " << msg << '\n'; \
  17. } while (0)
  18. #define SCTL_ERROR(msg) \
  19. do { \
  20. std::cerr << "\n\033[1;31mError:\033[0m " << msg << '\n'; \
  21. abort(); \
  22. } while (0)
  23. #define SCTL_ASSERT_MSG(cond, msg) \
  24. do { \
  25. if (!(cond)) SCTL_ERROR(msg); \
  26. } while (0)
  27. #define SCTL_ASSERT(cond) \
  28. do { \
  29. if (!(cond)) { \
  30. fprintf(stderr, "\n%s:%d: %s: Assertion `%s' failed.\n", __FILE__, __LINE__, __PRETTY_FUNCTION__, #cond); \
  31. abort(); \
  32. } \
  33. } while (0)
  34. #define SCTL_UNUSED(x) (void)(x) // to ignore unused variable warning.
  35. namespace SCTL_NAMESPACE {
  36. #ifdef SCTL_MEMDEBUG
  37. template <class ValueType> class ConstIterator;
  38. template <class ValueType> class Iterator;
  39. template <class ValueType, Long DIM> class StaticArray;
  40. #else
  41. template <typename ValueType> using Iterator = ValueType*;
  42. template <typename ValueType> using ConstIterator = const ValueType*;
  43. template <typename ValueType, Long DIM> using StaticArray = ValueType[DIM];
  44. #endif
  45. }
  46. #include SCTL_INCLUDE(math_utils.hpp)
  47. #endif //_SCTL_COMMON_HPP_