Nui
assert.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #if !defined(__cpp_exceptions) && !defined(__EMSCRIPTEN__)
4 # include <nui/frontend/val.hpp>
5 #else
6 # include <iostream>
7 #endif
8 
9 #include <stdexcept>
10 
11 namespace Nui
12 {
13  inline void assertImpl(bool condition, const char* message)
14  {
15  if (!condition)
16  {
17 #ifdef __cpp_exceptions
18  throw std::runtime_error(message);
19 #elif defined(__EMSCRIPTEN__)
20  Nui::val::global("console").call<void>("error", message);
21 #else
22  std::cerr << message << std::endl;
23  std::terminate();
24 #endif
25  }
26  }
27 
28 #ifdef NDEBUG
29 # define NUI_ASSERT(condition, message)
30 #else
31 # define NUI_ASSERT(condition, message) assertImpl(condition, message)
32 #endif
33 }
Definition: file_dialog.hpp:6
void assertImpl(bool condition, const char *message)
Definition: assert.hpp:13