|
15 | 15 | # include "Hash/CityHash.h" |
16 | 16 | #endif |
17 | 17 | #ifdef INK_ENABLE_STL |
| 18 | +#ifdef INK_ENABLE_EXCEPTIONS |
18 | 19 | # include <exception> |
| 20 | +#endif |
19 | 21 | # include <stdexcept> |
20 | 22 | # include <optional> |
21 | 23 | # include <cctype> |
|
31 | 33 |
|
32 | 34 | #ifdef INK_ENABLE_UNREAL |
33 | 35 | # define inkZeroMemory(buff, len) FMemory::Memset(buff, 0, len) |
34 | | -# define inkAssert(condition, text, ...) checkf(condition, TEXT(text), ##__VA_ARGS__) |
35 | | -# define inkFail(text, ...) checkf(false, TEXT(text), ##__VA_ARGS__) |
36 | 36 | # define FORMAT_STRING_STR "%hs" |
37 | 37 | #else |
38 | 38 | # define inkZeroMemory ink::internal::zero_memory |
| 39 | +# define FORMAT_STRING_STR "%s" |
| 40 | +#endif |
| 41 | + |
| 42 | +#ifdef INK_ENABLE_UNREAL |
| 43 | +# define inkAssert(condition, text, ...) checkf(condition, TEXT(text), ##__VA_ARGS__) |
| 44 | +# define inkFail(text, ...) checkf(false, TEXT(text), ##__VA_ARGS__) |
| 45 | +#else |
39 | 46 | # define inkAssert ink::ink_assert |
40 | 47 | # define inkFail(...) ink::ink_assert(false, __VA_ARGS__) |
41 | | -# define FORMAT_STRING_STR "%s" |
42 | 48 | #endif |
43 | 49 |
|
44 | 50 | namespace ink |
@@ -175,7 +181,7 @@ namespace internal |
175 | 181 | #endif |
176 | 182 | } // namespace internal |
177 | 183 |
|
178 | | -#ifdef INK_ENABLE_STL |
| 184 | +#ifdef INK_ENABLE_EXCEPTIONS |
179 | 185 | /** exception type thrown if something goes wrong */ |
180 | 186 | using ink_exception = std::runtime_error; |
181 | 187 | #else |
@@ -209,9 +215,19 @@ void ink_assert(bool condition, const char* msg = nullptr, Args... args) |
209 | 215 | size_t size = snprintf(nullptr, 0, msg, args...) + 1; |
210 | 216 | char* message = static_cast<char*>(malloc(size)); |
211 | 217 | snprintf(message, size, msg, args...); |
| 218 | +#ifdef INK_ENABLE_EXCEPTIONS |
212 | 219 | throw ink_exception(message); |
| 220 | +#else |
| 221 | + fprintf(stderr, "Ink Assert: %s\n", message); |
| 222 | + abort(); |
| 223 | +#endif |
213 | 224 | } else { |
| 225 | +#ifdef INK_ENABLE_EXCEPTIONS |
214 | 226 | throw ink_exception(msg); |
| 227 | +#else |
| 228 | + fprintf(stderr, "Ink Assert: %s\n", msg); |
| 229 | + abort(); |
| 230 | +#endif |
215 | 231 | } |
216 | 232 | } |
217 | 233 | } |
|
0 commit comments