|
@@ -126,91 +126,84 @@ void _err_print_index_error(const char *p_function, const char *p_file, int p_li
|
|
* error message and returns from the function. This macro should be preferred to
|
|
* error message and returns from the function. This macro should be preferred to
|
|
* `ERR_FAIL_COND` for bounds checking.
|
|
* `ERR_FAIL_COND` for bounds checking.
|
|
*/
|
|
*/
|
|
-#define ERR_FAIL_INDEX(m_index, m_size) \
|
|
|
|
- do { \
|
|
|
|
- if (unlikely((m_index) < 0 || (m_index) >= (m_size))) { \
|
|
|
|
- _err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size)); \
|
|
|
|
- return; \
|
|
|
|
- } \
|
|
|
|
- } while (0); // (*)
|
|
|
|
|
|
+#define ERR_FAIL_INDEX(m_index, m_size) \
|
|
|
|
+ if (unlikely((m_index) < 0 || (m_index) >= (m_size))) { \
|
|
|
|
+ _err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size)); \
|
|
|
|
+ return; \
|
|
|
|
+ } else \
|
|
|
|
+ ((void)0)
|
|
|
|
|
|
/**
|
|
/**
|
|
* If `m_index` is less than 0 or greater than or equal to `m_size`, prints a custom
|
|
* If `m_index` is less than 0 or greater than or equal to `m_size`, prints a custom
|
|
* error message and returns from the function. This macro should be preferred to
|
|
* error message and returns from the function. This macro should be preferred to
|
|
* `ERR_FAIL_COND_MSG` for bounds checking.
|
|
* `ERR_FAIL_COND_MSG` for bounds checking.
|
|
*/
|
|
*/
|
|
-#define ERR_FAIL_INDEX_MSG(m_index, m_size, m_msg) \
|
|
|
|
- do { \
|
|
|
|
- if (unlikely((m_index) < 0 || (m_index) >= (m_size))) { \
|
|
|
|
- _err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size), DEBUG_STR(m_msg)); \
|
|
|
|
- return; \
|
|
|
|
- } \
|
|
|
|
- } while (0); // (*)
|
|
|
|
|
|
+#define ERR_FAIL_INDEX_MSG(m_index, m_size, m_msg) \
|
|
|
|
+ if (unlikely((m_index) < 0 || (m_index) >= (m_size))) { \
|
|
|
|
+ _err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size), DEBUG_STR(m_msg)); \
|
|
|
|
+ return; \
|
|
|
|
+ } else \
|
|
|
|
+ ((void)0)
|
|
|
|
|
|
/**
|
|
/**
|
|
* If `m_index` is less than 0 or greater than or equal to `m_size`,
|
|
* If `m_index` is less than 0 or greater than or equal to `m_size`,
|
|
* prints a generic error message and returns the value specified in `m_retval`.
|
|
* prints a generic error message and returns the value specified in `m_retval`.
|
|
* This macro should be preferred to `ERR_FAIL_COND_V` for bounds checking.
|
|
* This macro should be preferred to `ERR_FAIL_COND_V` for bounds checking.
|
|
*/
|
|
*/
|
|
-#define ERR_FAIL_INDEX_V(m_index, m_size, m_retval) \
|
|
|
|
- do { \
|
|
|
|
- if (unlikely((m_index) < 0 || (m_index) >= (m_size))) { \
|
|
|
|
- _err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size)); \
|
|
|
|
- return m_retval; \
|
|
|
|
- } \
|
|
|
|
- } while (0); // (*)
|
|
|
|
|
|
+#define ERR_FAIL_INDEX_V(m_index, m_size, m_retval) \
|
|
|
|
+ if (unlikely((m_index) < 0 || (m_index) >= (m_size))) { \
|
|
|
|
+ _err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size)); \
|
|
|
|
+ return m_retval; \
|
|
|
|
+ } else \
|
|
|
|
+ ((void)0)
|
|
|
|
|
|
/**
|
|
/**
|
|
* If `m_index` is less than 0 or greater than or equal to `m_size`,
|
|
* If `m_index` is less than 0 or greater than or equal to `m_size`,
|
|
* prints a custom error message and returns the value specified in `m_retval`.
|
|
* prints a custom error message and returns the value specified in `m_retval`.
|
|
* This macro should be preferred to `ERR_FAIL_COND_V_MSG` for bounds checking.
|
|
* This macro should be preferred to `ERR_FAIL_COND_V_MSG` for bounds checking.
|
|
*/
|
|
*/
|
|
-#define ERR_FAIL_INDEX_V_MSG(m_index, m_size, m_retval, m_msg) \
|
|
|
|
- do { \
|
|
|
|
- if (unlikely((m_index) < 0 || (m_index) >= (m_size))) { \
|
|
|
|
- _err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size), DEBUG_STR(m_msg)); \
|
|
|
|
- return m_retval; \
|
|
|
|
- } \
|
|
|
|
- } while (0); // (*)
|
|
|
|
|
|
+#define ERR_FAIL_INDEX_V_MSG(m_index, m_size, m_retval, m_msg) \
|
|
|
|
+ if (unlikely((m_index) < 0 || (m_index) >= (m_size))) { \
|
|
|
|
+ _err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size), DEBUG_STR(m_msg)); \
|
|
|
|
+ return m_retval; \
|
|
|
|
+ } else \
|
|
|
|
+ ((void)0)
|
|
|
|
|
|
/**
|
|
/**
|
|
* If `m_index` is greater than or equal to `m_size`,
|
|
* If `m_index` is greater than or equal to `m_size`,
|
|
* prints a generic error message and returns the value specified in `m_retval`.
|
|
* prints a generic error message and returns the value specified in `m_retval`.
|
|
* This macro should be preferred to `ERR_FAIL_COND_V` for unsigned bounds checking.
|
|
* This macro should be preferred to `ERR_FAIL_COND_V` for unsigned bounds checking.
|
|
*/
|
|
*/
|
|
-#define ERR_FAIL_UNSIGNED_INDEX(m_index, m_size) \
|
|
|
|
- do { \
|
|
|
|
- if (unlikely((m_index) >= (m_size))) { \
|
|
|
|
- _err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size)); \
|
|
|
|
- return; \
|
|
|
|
- } \
|
|
|
|
- } while (0); // (*)
|
|
|
|
|
|
+#define ERR_FAIL_UNSIGNED_INDEX(m_index, m_size) \
|
|
|
|
+ if (unlikely((m_index) >= (m_size))) { \
|
|
|
|
+ _err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size)); \
|
|
|
|
+ return; \
|
|
|
|
+ } else \
|
|
|
|
+ ((void)0)
|
|
|
|
|
|
/**
|
|
/**
|
|
* If `m_index` is greater than or equal to `m_size`,
|
|
* If `m_index` is greater than or equal to `m_size`,
|
|
* prints a generic error message and returns the value specified in `m_retval`.
|
|
* prints a generic error message and returns the value specified in `m_retval`.
|
|
* This macro should be preferred to `ERR_FAIL_COND_V` for unsigned bounds checking.
|
|
* This macro should be preferred to `ERR_FAIL_COND_V` for unsigned bounds checking.
|
|
*/
|
|
*/
|
|
-#define ERR_FAIL_UNSIGNED_INDEX_V(m_index, m_size, m_retval) \
|
|
|
|
- do { \
|
|
|
|
- if (unlikely((m_index) >= (m_size))) { \
|
|
|
|
- _err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size)); \
|
|
|
|
- return m_retval; \
|
|
|
|
- } \
|
|
|
|
- } while (0); // (*)
|
|
|
|
|
|
+#define ERR_FAIL_UNSIGNED_INDEX_V(m_index, m_size, m_retval) \
|
|
|
|
+ if (unlikely((m_index) >= (m_size))) { \
|
|
|
|
+ _err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size)); \
|
|
|
|
+ return m_retval; \
|
|
|
|
+ } else \
|
|
|
|
+ ((void)0)
|
|
|
|
|
|
/**
|
|
/**
|
|
* If `m_index` is greater than or equal to `m_size`,
|
|
* If `m_index` is greater than or equal to `m_size`,
|
|
* prints a custom error message and returns the value specified in `m_retval`.
|
|
* prints a custom error message and returns the value specified in `m_retval`.
|
|
* This macro should be preferred to `ERR_FAIL_COND_V_MSG` for unsigned bounds checking.
|
|
* This macro should be preferred to `ERR_FAIL_COND_V_MSG` for unsigned bounds checking.
|
|
*/
|
|
*/
|
|
-#define ERR_FAIL_UNSIGNED_INDEX_V_MSG(m_index, m_size, m_retval, m_msg) \
|
|
|
|
- do { \
|
|
|
|
- if (unlikely((m_index) >= (m_size))) { \
|
|
|
|
- _err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size), DEBUG_STR(m_msg)); \
|
|
|
|
- return m_retval; \
|
|
|
|
- } \
|
|
|
|
- } while (0); // (*)
|
|
|
|
|
|
+#define ERR_FAIL_UNSIGNED_INDEX_V_MSG(m_index, m_size, m_retval, m_msg) \
|
|
|
|
+ if (unlikely((m_index) >= (m_size))) { \
|
|
|
|
+ _err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size), DEBUG_STR(m_msg)); \
|
|
|
|
+ return m_retval; \
|
|
|
|
+ } else \
|
|
|
|
+ ((void)0)
|
|
|
|
|
|
/**
|
|
/**
|
|
* If `m_index` is less than 0 or greater than or equal to `m_size`,
|
|
* If `m_index` is less than 0 or greater than or equal to `m_size`,
|
|
@@ -218,13 +211,12 @@ void _err_print_index_error(const char *p_function, const char *p_file, int p_li
|
|
* Only use this if there's no sensible fallback (i.e. the error is unrecoverable).
|
|
* Only use this if there's no sensible fallback (i.e. the error is unrecoverable).
|
|
* This macro should be preferred to `CRASH_COND` for bounds checking.
|
|
* This macro should be preferred to `CRASH_COND` for bounds checking.
|
|
*/
|
|
*/
|
|
-#define CRASH_BAD_INDEX(m_index, m_size) \
|
|
|
|
- do { \
|
|
|
|
- if (unlikely((m_index) < 0 || (m_index) >= (m_size))) { \
|
|
|
|
- _err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size), "", true); \
|
|
|
|
- GENERATE_TRAP \
|
|
|
|
- } \
|
|
|
|
- } while (0); // (*)
|
|
|
|
|
|
+#define CRASH_BAD_INDEX(m_index, m_size) \
|
|
|
|
+ if (unlikely((m_index) < 0 || (m_index) >= (m_size))) { \
|
|
|
|
+ _err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size), "", true); \
|
|
|
|
+ GENERATE_TRAP \
|
|
|
|
+ } else \
|
|
|
|
+ ((void)0)
|
|
|
|
|
|
/**
|
|
/**
|
|
* If `m_index` is less than 0 or greater than or equal to `m_size`,
|
|
* If `m_index` is less than 0 or greater than or equal to `m_size`,
|
|
@@ -232,13 +224,12 @@ void _err_print_index_error(const char *p_function, const char *p_file, int p_li
|
|
* Only use this if there's no sensible fallback (i.e. the error is unrecoverable).
|
|
* Only use this if there's no sensible fallback (i.e. the error is unrecoverable).
|
|
* This macro should be preferred to `CRASH_COND` for bounds checking.
|
|
* This macro should be preferred to `CRASH_COND` for bounds checking.
|
|
*/
|
|
*/
|
|
-#define CRASH_BAD_INDEX_MSG(m_index, m_size, m_msg) \
|
|
|
|
- do { \
|
|
|
|
- if (unlikely((m_index) < 0 || (m_index) >= (m_size))) { \
|
|
|
|
- _err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size), m_msg, true); \
|
|
|
|
- GENERATE_TRAP \
|
|
|
|
- } \
|
|
|
|
- } while (0); // (*)
|
|
|
|
|
|
+#define CRASH_BAD_INDEX_MSG(m_index, m_size, m_msg) \
|
|
|
|
+ if (unlikely((m_index) < 0 || (m_index) >= (m_size))) { \
|
|
|
|
+ _err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size), m_msg, true); \
|
|
|
|
+ GENERATE_TRAP \
|
|
|
|
+ } else \
|
|
|
|
+ ((void)0)
|
|
|
|
|
|
/**
|
|
/**
|
|
* If `m_index` is greater than or equal to `m_size`,
|
|
* If `m_index` is greater than or equal to `m_size`,
|
|
@@ -246,79 +237,72 @@ void _err_print_index_error(const char *p_function, const char *p_file, int p_li
|
|
* Only use this if there's no sensible fallback (i.e. the error is unrecoverable).
|
|
* Only use this if there's no sensible fallback (i.e. the error is unrecoverable).
|
|
* This macro should be preferred to `CRASH_COND` for bounds checking.
|
|
* This macro should be preferred to `CRASH_COND` for bounds checking.
|
|
*/
|
|
*/
|
|
-#define CRASH_BAD_UNSIGNED_INDEX(m_index, m_size) \
|
|
|
|
- do { \
|
|
|
|
- if (unlikely((m_index) >= (m_size))) { \
|
|
|
|
- _err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size), "", true); \
|
|
|
|
- GENERATE_TRAP \
|
|
|
|
- } \
|
|
|
|
- } while (0); // (*)
|
|
|
|
|
|
+#define CRASH_BAD_UNSIGNED_INDEX(m_index, m_size) \
|
|
|
|
+ if (unlikely((m_index) >= (m_size))) { \
|
|
|
|
+ _err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size), "", true); \
|
|
|
|
+ GENERATE_TRAP \
|
|
|
|
+ } else \
|
|
|
|
+ ((void)0)
|
|
|
|
|
|
/**
|
|
/**
|
|
* If `m_param` is `null`, prints a generic error message and returns from the function.
|
|
* If `m_param` is `null`, prints a generic error message and returns from the function.
|
|
*/
|
|
*/
|
|
-#define ERR_FAIL_NULL(m_param) \
|
|
|
|
- { \
|
|
|
|
- if (unlikely(!m_param)) { \
|
|
|
|
- _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Parameter \"" _STR(m_param) "\" is null."); \
|
|
|
|
- return; \
|
|
|
|
- } \
|
|
|
|
- }
|
|
|
|
|
|
+#define ERR_FAIL_NULL(m_param) \
|
|
|
|
+ if (unlikely(!m_param)) { \
|
|
|
|
+ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Parameter \"" _STR(m_param) "\" is null."); \
|
|
|
|
+ return; \
|
|
|
|
+ } else \
|
|
|
|
+ ((void)0)
|
|
|
|
|
|
/**
|
|
/**
|
|
* If `m_param` is `null`, prints a custom error message and returns from the function.
|
|
* If `m_param` is `null`, prints a custom error message and returns from the function.
|
|
*/
|
|
*/
|
|
-#define ERR_FAIL_NULL_MSG(m_param, m_msg) \
|
|
|
|
- { \
|
|
|
|
- if (unlikely(!m_param)) { \
|
|
|
|
- _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Parameter \"" _STR(m_param) "\" is null.", DEBUG_STR(m_msg)); \
|
|
|
|
- return; \
|
|
|
|
- } \
|
|
|
|
- }
|
|
|
|
|
|
+#define ERR_FAIL_NULL_MSG(m_param, m_msg) \
|
|
|
|
+ if (unlikely(!m_param)) { \
|
|
|
|
+ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Parameter \"" _STR(m_param) "\" is null.", DEBUG_STR(m_msg)); \
|
|
|
|
+ return; \
|
|
|
|
+ } else \
|
|
|
|
+ ((void)0)
|
|
|
|
|
|
/**
|
|
/**
|
|
* If `m_param` is `null`, prints a generic error message and returns the value specified in `m_retval`.
|
|
* If `m_param` is `null`, prints a generic error message and returns the value specified in `m_retval`.
|
|
*/
|
|
*/
|
|
-#define ERR_FAIL_NULL_V(m_param, m_retval) \
|
|
|
|
- { \
|
|
|
|
- if (unlikely(!m_param)) { \
|
|
|
|
- _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Parameter \"" _STR(m_param) "\" is null."); \
|
|
|
|
- return m_retval; \
|
|
|
|
- } \
|
|
|
|
- }
|
|
|
|
|
|
+#define ERR_FAIL_NULL_V(m_param, m_retval) \
|
|
|
|
+ if (unlikely(!m_param)) { \
|
|
|
|
+ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Parameter \"" _STR(m_param) "\" is null."); \
|
|
|
|
+ return m_retval; \
|
|
|
|
+ } else \
|
|
|
|
+ ((void)0)
|
|
|
|
|
|
/**
|
|
/**
|
|
* If `m_param` is `null`, prints a custom error message and returns the value specified in `m_retval`.
|
|
* If `m_param` is `null`, prints a custom error message and returns the value specified in `m_retval`.
|
|
*/
|
|
*/
|
|
-#define ERR_FAIL_NULL_V_MSG(m_param, m_retval, m_msg) \
|
|
|
|
- { \
|
|
|
|
- if (unlikely(!m_param)) { \
|
|
|
|
- _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Parameter \"" _STR(m_param) "\" is null.", DEBUG_STR(m_msg)); \
|
|
|
|
- return m_retval; \
|
|
|
|
- } \
|
|
|
|
- }
|
|
|
|
|
|
+#define ERR_FAIL_NULL_V_MSG(m_param, m_retval, m_msg) \
|
|
|
|
+ if (unlikely(!m_param)) { \
|
|
|
|
+ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Parameter \"" _STR(m_param) "\" is null.", DEBUG_STR(m_msg)); \
|
|
|
|
+ return m_retval; \
|
|
|
|
+ } else \
|
|
|
|
+ ((void)0)
|
|
|
|
|
|
/**
|
|
/**
|
|
* If `m_cond` evaluates to `true`, prints a generic error message and returns from the function.
|
|
* If `m_cond` evaluates to `true`, prints a generic error message and returns from the function.
|
|
*/
|
|
*/
|
|
-#define ERR_FAIL_COND(m_cond) \
|
|
|
|
- { \
|
|
|
|
- if (unlikely(m_cond)) { \
|
|
|
|
- _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition \"" _STR(m_cond) "\" is true."); \
|
|
|
|
- return; \
|
|
|
|
- } \
|
|
|
|
- }
|
|
|
|
|
|
+#define ERR_FAIL_COND(m_cond) \
|
|
|
|
+ if (unlikely(m_cond)) { \
|
|
|
|
+ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition \"" _STR(m_cond) "\" is true."); \
|
|
|
|
+ return; \
|
|
|
|
+ } else \
|
|
|
|
+ ((void)0)
|
|
|
|
|
|
/**
|
|
/**
|
|
* If `m_cond` evaluates to `true`, prints a custom error message and returns from the function.
|
|
* If `m_cond` evaluates to `true`, prints a custom error message and returns from the function.
|
|
*/
|
|
*/
|
|
-#define ERR_FAIL_COND_MSG(m_cond, m_msg) \
|
|
|
|
- { \
|
|
|
|
- if (unlikely(m_cond)) { \
|
|
|
|
- _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition \"" _STR(m_cond) "\" is true.", DEBUG_STR(m_msg)); \
|
|
|
|
- return; \
|
|
|
|
- } \
|
|
|
|
- }
|
|
|
|
|
|
+#define ERR_FAIL_COND_MSG(m_cond, m_msg) \
|
|
|
|
+ if (unlikely(m_cond)) { \
|
|
|
|
+ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition \"" _STR(m_cond) "\" is true.", DEBUG_STR(m_msg)); \
|
|
|
|
+ return; \
|
|
|
|
+ } else \
|
|
|
|
+ ((void)0)
|
|
|
|
|
|
/**
|
|
/**
|
|
* Should assert only if making a build with dev asserts.
|
|
* Should assert only if making a build with dev asserts.
|
|
@@ -327,13 +311,12 @@ void _err_print_index_error(const char *p_function, const char *p_file, int p_li
|
|
*/
|
|
*/
|
|
// #define DEV_ASSERTS_ENABLED
|
|
// #define DEV_ASSERTS_ENABLED
|
|
#ifdef DEV_ASSERTS_ENABLED
|
|
#ifdef DEV_ASSERTS_ENABLED
|
|
-#define DEV_ASSERT(m_cond) \
|
|
|
|
- { \
|
|
|
|
- if (unlikely(!(m_cond))) { \
|
|
|
|
- _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "FATAL: DEV_ASSERT failed \"" _STR(m_cond) "\" is false."); \
|
|
|
|
- GENERATE_TRAP \
|
|
|
|
- } \
|
|
|
|
- }
|
|
|
|
|
|
+#define DEV_ASSERT(m_cond) \
|
|
|
|
+ if (unlikely(!(m_cond))) { \
|
|
|
|
+ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "FATAL: DEV_ASSERT failed \"" _STR(m_cond) "\" is false."); \
|
|
|
|
+ GENERATE_TRAP \
|
|
|
|
+ } else \
|
|
|
|
+ ((void)0)
|
|
#else
|
|
#else
|
|
#define DEV_ASSERT(m_cond)
|
|
#define DEV_ASSERT(m_cond)
|
|
#endif
|
|
#endif
|
|
@@ -342,215 +325,213 @@ void _err_print_index_error(const char *p_function, const char *p_file, int p_li
|
|
* If `m_cond` evaluates to `true`, crashes the engine immediately with a generic error message.
|
|
* If `m_cond` evaluates to `true`, crashes the engine immediately with a generic error message.
|
|
* Only use this if there's no sensible fallback (i.e. the error is unrecoverable).
|
|
* Only use this if there's no sensible fallback (i.e. the error is unrecoverable).
|
|
*/
|
|
*/
|
|
-#define CRASH_COND(m_cond) \
|
|
|
|
- { \
|
|
|
|
- if (unlikely(m_cond)) { \
|
|
|
|
- _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "FATAL: Condition \"" _STR(m_cond) "\" is true."); \
|
|
|
|
- GENERATE_TRAP \
|
|
|
|
- } \
|
|
|
|
- }
|
|
|
|
|
|
+#define CRASH_COND(m_cond) \
|
|
|
|
+ if (unlikely(m_cond)) { \
|
|
|
|
+ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "FATAL: Condition \"" _STR(m_cond) "\" is true."); \
|
|
|
|
+ GENERATE_TRAP \
|
|
|
|
+ } else \
|
|
|
|
+ ((void)0)
|
|
|
|
|
|
/**
|
|
/**
|
|
* If `m_cond` evaluates to `true`, crashes the engine immediately with a custom error message.
|
|
* If `m_cond` evaluates to `true`, crashes the engine immediately with a custom error message.
|
|
* Only use this if there's no sensible fallback (i.e. the error is unrecoverable).
|
|
* Only use this if there's no sensible fallback (i.e. the error is unrecoverable).
|
|
*/
|
|
*/
|
|
-#define CRASH_COND_MSG(m_cond, m_msg) \
|
|
|
|
- { \
|
|
|
|
- if (unlikely(m_cond)) { \
|
|
|
|
- _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "FATAL: Condition \"" _STR(m_cond) "\" is true.", DEBUG_STR(m_msg)); \
|
|
|
|
- GENERATE_TRAP \
|
|
|
|
- } \
|
|
|
|
- }
|
|
|
|
|
|
+#define CRASH_COND_MSG(m_cond, m_msg) \
|
|
|
|
+ if (unlikely(m_cond)) { \
|
|
|
|
+ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "FATAL: Condition \"" _STR(m_cond) "\" is true.", DEBUG_STR(m_msg)); \
|
|
|
|
+ GENERATE_TRAP \
|
|
|
|
+ } else \
|
|
|
|
+ ((void)0)
|
|
|
|
|
|
/**
|
|
/**
|
|
* If `m_cond` evaluates to `true`, prints a generic error message and returns the value specified in `m_retval`.
|
|
* If `m_cond` evaluates to `true`, prints a generic error message and returns the value specified in `m_retval`.
|
|
*/
|
|
*/
|
|
-#define ERR_FAIL_COND_V(m_cond, m_retval) \
|
|
|
|
- { \
|
|
|
|
- if (unlikely(m_cond)) { \
|
|
|
|
- _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition \"" _STR(m_cond) "\" is true. Returned: " _STR(m_retval)); \
|
|
|
|
- return m_retval; \
|
|
|
|
- } \
|
|
|
|
- }
|
|
|
|
|
|
+#define ERR_FAIL_COND_V(m_cond, m_retval) \
|
|
|
|
+ if (unlikely(m_cond)) { \
|
|
|
|
+ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition \"" _STR(m_cond) "\" is true. Returned: " _STR(m_retval)); \
|
|
|
|
+ return m_retval; \
|
|
|
|
+ } else \
|
|
|
|
+ ((void)0)
|
|
|
|
|
|
/**
|
|
/**
|
|
* If `m_cond` evaluates to `true`, prints a custom error message and returns the value specified in `m_retval`.
|
|
* If `m_cond` evaluates to `true`, prints a custom error message and returns the value specified in `m_retval`.
|
|
*/
|
|
*/
|
|
-#define ERR_FAIL_COND_V_MSG(m_cond, m_retval, m_msg) \
|
|
|
|
- { \
|
|
|
|
- if (unlikely(m_cond)) { \
|
|
|
|
- _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition \"" _STR(m_cond) "\" is true. Returned: " _STR(m_retval), DEBUG_STR(m_msg)); \
|
|
|
|
- return m_retval; \
|
|
|
|
- } \
|
|
|
|
- }
|
|
|
|
|
|
+#define ERR_FAIL_COND_V_MSG(m_cond, m_retval, m_msg) \
|
|
|
|
+ if (unlikely(m_cond)) { \
|
|
|
|
+ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition \"" _STR(m_cond) "\" is true. Returned: " _STR(m_retval), DEBUG_STR(m_msg)); \
|
|
|
|
+ return m_retval; \
|
|
|
|
+ } else \
|
|
|
|
+ ((void)0)
|
|
|
|
|
|
/**
|
|
/**
|
|
* If `m_cond` evaluates to `true`, prints a custom error message and continues the loop the macro is located in.
|
|
* If `m_cond` evaluates to `true`, prints a custom error message and continues the loop the macro is located in.
|
|
*/
|
|
*/
|
|
-#define ERR_CONTINUE(m_cond) \
|
|
|
|
- { \
|
|
|
|
- if (unlikely(m_cond)) { \
|
|
|
|
- _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition \"" _STR(m_cond) "\" is true. Continuing."); \
|
|
|
|
- continue; \
|
|
|
|
- } \
|
|
|
|
- }
|
|
|
|
|
|
+#define ERR_CONTINUE(m_cond) \
|
|
|
|
+ if (unlikely(m_cond)) { \
|
|
|
|
+ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition \"" _STR(m_cond) "\" is true. Continuing."); \
|
|
|
|
+ continue; \
|
|
|
|
+ } else \
|
|
|
|
+ ((void)0)
|
|
|
|
|
|
/**
|
|
/**
|
|
* If `m_cond` evaluates to `true`, prints a custom error message and continues the loop the macro is located in.
|
|
* If `m_cond` evaluates to `true`, prints a custom error message and continues the loop the macro is located in.
|
|
*/
|
|
*/
|
|
-#define ERR_CONTINUE_MSG(m_cond, m_msg) \
|
|
|
|
- { \
|
|
|
|
- if (unlikely(m_cond)) { \
|
|
|
|
- _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition \"" _STR(m_cond) "\" is true. Continuing.", DEBUG_STR(m_msg)); \
|
|
|
|
- continue; \
|
|
|
|
- } \
|
|
|
|
- }
|
|
|
|
|
|
+#define ERR_CONTINUE_MSG(m_cond, m_msg) \
|
|
|
|
+ if (unlikely(m_cond)) { \
|
|
|
|
+ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition \"" _STR(m_cond) "\" is true. Continuing.", DEBUG_STR(m_msg)); \
|
|
|
|
+ continue; \
|
|
|
|
+ } else \
|
|
|
|
+ ((void)0)
|
|
|
|
|
|
/**
|
|
/**
|
|
* If `m_cond` evaluates to `true`, prints a generic error message and breaks from the loop the macro is located in.
|
|
* If `m_cond` evaluates to `true`, prints a generic error message and breaks from the loop the macro is located in.
|
|
*/
|
|
*/
|
|
-#define ERR_BREAK(m_cond) \
|
|
|
|
- { \
|
|
|
|
- if (unlikely(m_cond)) { \
|
|
|
|
- _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition \"" _STR(m_cond) "\" is true. Breaking."); \
|
|
|
|
- break; \
|
|
|
|
- } \
|
|
|
|
- }
|
|
|
|
|
|
+#define ERR_BREAK(m_cond) \
|
|
|
|
+ if (unlikely(m_cond)) { \
|
|
|
|
+ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition \"" _STR(m_cond) "\" is true. Breaking."); \
|
|
|
|
+ break; \
|
|
|
|
+ } else \
|
|
|
|
+ ((void)0)
|
|
|
|
|
|
/**
|
|
/**
|
|
* If `m_cond` evaluates to `true`, prints a custom error message and breaks from the loop the macro is located in.
|
|
* If `m_cond` evaluates to `true`, prints a custom error message and breaks from the loop the macro is located in.
|
|
*/
|
|
*/
|
|
-#define ERR_BREAK_MSG(m_cond, m_msg) \
|
|
|
|
- { \
|
|
|
|
- if (unlikely(m_cond)) { \
|
|
|
|
- _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition \"" _STR(m_cond) "\" is true. Breaking.", DEBUG_STR(m_msg)); \
|
|
|
|
- break; \
|
|
|
|
- } \
|
|
|
|
- }
|
|
|
|
|
|
+#define ERR_BREAK_MSG(m_cond, m_msg) \
|
|
|
|
+ if (unlikely(m_cond)) { \
|
|
|
|
+ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition \"" _STR(m_cond) "\" is true. Breaking.", DEBUG_STR(m_msg)); \
|
|
|
|
+ break; \
|
|
|
|
+ } else \
|
|
|
|
+ ((void)0)
|
|
|
|
|
|
/**
|
|
/**
|
|
* Prints a generic error message and returns from the function.
|
|
* Prints a generic error message and returns from the function.
|
|
*/
|
|
*/
|
|
#define ERR_FAIL() \
|
|
#define ERR_FAIL() \
|
|
- { \
|
|
|
|
|
|
+ if (true) { \
|
|
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Method failed."); \
|
|
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Method failed."); \
|
|
return; \
|
|
return; \
|
|
- }
|
|
|
|
|
|
+ } else \
|
|
|
|
+ ((void)0)
|
|
|
|
|
|
/**
|
|
/**
|
|
* Prints a custom error message and returns from the function.
|
|
* Prints a custom error message and returns from the function.
|
|
*/
|
|
*/
|
|
#define ERR_FAIL_MSG(m_msg) \
|
|
#define ERR_FAIL_MSG(m_msg) \
|
|
- { \
|
|
|
|
|
|
+ if (true) { \
|
|
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Method failed.", DEBUG_STR(m_msg)); \
|
|
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Method failed.", DEBUG_STR(m_msg)); \
|
|
return; \
|
|
return; \
|
|
- }
|
|
|
|
|
|
+ } else \
|
|
|
|
+ ((void)0)
|
|
|
|
|
|
/**
|
|
/**
|
|
* Prints a generic error message and returns the value specified in `m_retval`.
|
|
* Prints a generic error message and returns the value specified in `m_retval`.
|
|
*/
|
|
*/
|
|
#define ERR_FAIL_V(m_retval) \
|
|
#define ERR_FAIL_V(m_retval) \
|
|
- { \
|
|
|
|
|
|
+ if (true) { \
|
|
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Method failed. Returning: " __STR(m_retval)); \
|
|
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Method failed. Returning: " __STR(m_retval)); \
|
|
return m_retval; \
|
|
return m_retval; \
|
|
- }
|
|
|
|
|
|
+ } else \
|
|
|
|
+ ((void)0)
|
|
|
|
|
|
/**
|
|
/**
|
|
* Prints a custom error message and returns the value specified in `m_retval`.
|
|
* Prints a custom error message and returns the value specified in `m_retval`.
|
|
*/
|
|
*/
|
|
#define ERR_FAIL_V_MSG(m_retval, m_msg) \
|
|
#define ERR_FAIL_V_MSG(m_retval, m_msg) \
|
|
- { \
|
|
|
|
|
|
+ if (true) { \
|
|
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Method failed. Returning: " __STR(m_retval), DEBUG_STR(m_msg)); \
|
|
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Method failed. Returning: " __STR(m_retval), DEBUG_STR(m_msg)); \
|
|
return m_retval; \
|
|
return m_retval; \
|
|
- }
|
|
|
|
|
|
+ } else \
|
|
|
|
+ ((void)0)
|
|
|
|
|
|
/**
|
|
/**
|
|
* Crashes the engine immediately with a generic error message.
|
|
* Crashes the engine immediately with a generic error message.
|
|
* Only use this if there's no sensible fallback (i.e. the error is unrecoverable).
|
|
* Only use this if there's no sensible fallback (i.e. the error is unrecoverable).
|
|
*/
|
|
*/
|
|
#define CRASH_NOW() \
|
|
#define CRASH_NOW() \
|
|
- { \
|
|
|
|
|
|
+ if (true) { \
|
|
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "FATAL: Method failed."); \
|
|
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "FATAL: Method failed."); \
|
|
GENERATE_TRAP \
|
|
GENERATE_TRAP \
|
|
- }
|
|
|
|
|
|
+ } else \
|
|
|
|
+ ((void)0)
|
|
|
|
|
|
/**
|
|
/**
|
|
* Crashes the engine immediately with a custom error message.
|
|
* Crashes the engine immediately with a custom error message.
|
|
* Only use this if there's no sensible fallback (i.e. the error is unrecoverable).
|
|
* Only use this if there's no sensible fallback (i.e. the error is unrecoverable).
|
|
*/
|
|
*/
|
|
#define CRASH_NOW_MSG(m_msg) \
|
|
#define CRASH_NOW_MSG(m_msg) \
|
|
- { \
|
|
|
|
|
|
+ if (true) { \
|
|
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "FATAL: Method failed.", DEBUG_STR(m_msg)); \
|
|
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "FATAL: Method failed.", DEBUG_STR(m_msg)); \
|
|
GENERATE_TRAP \
|
|
GENERATE_TRAP \
|
|
- }
|
|
|
|
|
|
+ } else \
|
|
|
|
+ ((void)0)
|
|
|
|
|
|
/**
|
|
/**
|
|
* Prints an error message without returning.
|
|
* Prints an error message without returning.
|
|
*/
|
|
*/
|
|
-#define ERR_PRINT(m_string) \
|
|
|
|
- { \
|
|
|
|
- _err_print_error(FUNCTION_STR, __FILE__, __LINE__, m_string); \
|
|
|
|
- }
|
|
|
|
|
|
+#define ERR_PRINT(m_string) \
|
|
|
|
+ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, m_string)
|
|
|
|
|
|
/**
|
|
/**
|
|
* Prints an error message without returning, but only do so once in the application lifecycle.
|
|
* Prints an error message without returning, but only do so once in the application lifecycle.
|
|
* This can be used to avoid spamming the console with error messages.
|
|
* This can be used to avoid spamming the console with error messages.
|
|
*/
|
|
*/
|
|
#define ERR_PRINT_ONCE(m_string) \
|
|
#define ERR_PRINT_ONCE(m_string) \
|
|
- { \
|
|
|
|
|
|
+ if (true) { \
|
|
static bool first_print = true; \
|
|
static bool first_print = true; \
|
|
if (first_print) { \
|
|
if (first_print) { \
|
|
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, m_string); \
|
|
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, m_string); \
|
|
first_print = false; \
|
|
first_print = false; \
|
|
} \
|
|
} \
|
|
- }
|
|
|
|
|
|
+ } else \
|
|
|
|
+ ((void)0)
|
|
|
|
|
|
/**
|
|
/**
|
|
* Prints a warning message without returning. To warn about deprecated usage,
|
|
* Prints a warning message without returning. To warn about deprecated usage,
|
|
* use `WARN_DEPRECATED` or `WARN_DEPRECATED_MSG` instead.
|
|
* use `WARN_DEPRECATED` or `WARN_DEPRECATED_MSG` instead.
|
|
*/
|
|
*/
|
|
-#define WARN_PRINT(m_string) \
|
|
|
|
- { \
|
|
|
|
- _err_print_error(FUNCTION_STR, __FILE__, __LINE__, m_string, ERR_HANDLER_WARNING); \
|
|
|
|
- }
|
|
|
|
|
|
+#define WARN_PRINT(m_string) \
|
|
|
|
+ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, m_string, ERR_HANDLER_WARNING)
|
|
|
|
|
|
/**
|
|
/**
|
|
* Prints a warning message without returning, but only do so once in the application lifecycle.
|
|
* Prints a warning message without returning, but only do so once in the application lifecycle.
|
|
* This can be used to avoid spamming the console with warning messages.
|
|
* This can be used to avoid spamming the console with warning messages.
|
|
*/
|
|
*/
|
|
#define WARN_PRINT_ONCE(m_string) \
|
|
#define WARN_PRINT_ONCE(m_string) \
|
|
- { \
|
|
|
|
|
|
+ if (true) { \
|
|
static bool first_print = true; \
|
|
static bool first_print = true; \
|
|
if (first_print) { \
|
|
if (first_print) { \
|
|
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, m_string, ERR_HANDLER_WARNING); \
|
|
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, m_string, ERR_HANDLER_WARNING); \
|
|
first_print = false; \
|
|
first_print = false; \
|
|
} \
|
|
} \
|
|
- }
|
|
|
|
|
|
+ } else \
|
|
|
|
+ ((void)0)
|
|
|
|
|
|
/**
|
|
/**
|
|
* Prints a generic deprecation warning message without returning.
|
|
* Prints a generic deprecation warning message without returning.
|
|
* This should be preferred to `WARN_PRINT` for deprecation warnings.
|
|
* This should be preferred to `WARN_PRINT` for deprecation warnings.
|
|
*/
|
|
*/
|
|
#define WARN_DEPRECATED \
|
|
#define WARN_DEPRECATED \
|
|
- { \
|
|
|
|
|
|
+ if (true) { \
|
|
static SafeFlag warning_shown; \
|
|
static SafeFlag warning_shown; \
|
|
if (!warning_shown.is_set()) { \
|
|
if (!warning_shown.is_set()) { \
|
|
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "This method has been deprecated and will be removed in the future.", ERR_HANDLER_WARNING); \
|
|
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "This method has been deprecated and will be removed in the future.", ERR_HANDLER_WARNING); \
|
|
warning_shown.set(); \
|
|
warning_shown.set(); \
|
|
} \
|
|
} \
|
|
- }
|
|
|
|
|
|
+ } else \
|
|
|
|
+ ((void)0)
|
|
|
|
|
|
/**
|
|
/**
|
|
* Prints a custom deprecation warning message without returning.
|
|
* Prints a custom deprecation warning message without returning.
|
|
* This should be preferred to `WARN_PRINT` for deprecation warnings.
|
|
* This should be preferred to `WARN_PRINT` for deprecation warnings.
|
|
*/
|
|
*/
|
|
#define WARN_DEPRECATED_MSG(m_msg) \
|
|
#define WARN_DEPRECATED_MSG(m_msg) \
|
|
- { \
|
|
|
|
|
|
+ if (true) { \
|
|
static SafeFlag warning_shown; \
|
|
static SafeFlag warning_shown; \
|
|
if (!warning_shown.is_set()) { \
|
|
if (!warning_shown.is_set()) { \
|
|
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "This method has been deprecated and will be removed in the future.", m_msg, ERR_HANDLER_WARNING); \
|
|
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "This method has been deprecated and will be removed in the future.", m_msg, ERR_HANDLER_WARNING); \
|
|
warning_shown.set(); \
|
|
warning_shown.set(); \
|
|
} \
|
|
} \
|
|
- }
|
|
|
|
|
|
+ } else \
|
|
|
|
+ ((void)0)
|
|
|
|
|
|
#endif
|
|
#endif
|