lv_check_arg.h
API reference for lv_check_arg.h
Macros
LV_LIKELY
#define LV_LIKELY(x) \
(x)LV_UNLIKELY
#define LV_UNLIKELY(x) \
(x)LV_CHECK_ARG_ASSERT_HANDLER_
#define LV_CHECK_ARG_ASSERT_HANDLER_ do {} while(0)LV_CHECK_ARG_LOG_
#define LV_CHECK_ARG_LOG_(cond_str, msg) \
do {} while(0)LV_CHECK_ARG_LOG_FORMAT_
#define LV_CHECK_ARG_LOG_FORMAT_(cond_str, format, ...) \
do {} while(0)LV_CHECK_ARG_INTERNAL_
#define LV_CHECK_ARG_INTERNAL_(cond, cond_str, action_on_fail, msg) \
if(LV_UNLIKELY(!(cond))) { \
LV_CHECK_ARG_LOG_(cond_str, msg); \
LV_CHECK_ARG_ASSERT_HANDLER_; \
action_on_fail; \
} else {}LV_CHECK_ARG_FORMAT_INTERNAL_
#define LV_CHECK_ARG_FORMAT_INTERNAL_(cond, cond_str, action_on_fail, format, ...) \
if(LV_UNLIKELY(!(cond))) { \
LV_CHECK_ARG_LOG_FORMAT_(cond_str, format, __VA_ARGS__); \
LV_CHECK_ARG_ASSERT_HANDLER_; \
action_on_fail; \
} else {}LV_CHECK_ARG
#define LV_CHECK_ARG(cond, action_on_fail) \
LV_CHECK_ARG_INTERNAL_(cond, #cond, action_on_fail, "")Check that a condition is true. If the condition is false, log a warning and execute action_on_fail (e.g. return, return val, break).
Can be disabled entirely by setting LV_USE_CHECK_ARG to 0 in lv_conf.h. If LV_CHECK_ARG_ASSERT_ON_FAIL is 1, LV_ASSERT_HANDLER is also invoked before the action. Log output requires LV_USE_LOG to be enabled; if LV_USE_LOG is 0 no output is produced regardless of LV_CHECK_ARG_LOG_MODE.
Example:
LV_CHECK_ARG(ptr != NULL, return);| Name | Description |
|---|---|
cond | condition to check |
action_on_fail | statement to execute on failure (e.g. return, return 0, break) |
LV_CHECK_ARG_MSG
#define LV_CHECK_ARG_MSG(cond, action_on_fail, msg) \
LV_CHECK_ARG_INTERNAL_(cond, #cond, action_on_fail, " " msg)Same as LV_CHECK_ARG but a message is appended to the log. The message is only used when LV_CHECK_ARG_LOG_MODE is set to VERBOSE.
Example:
LV_CHECK_ARG_MSG(ptr != NULL, return, "pointer must not be NULL");| Name | Description |
|---|---|
cond | condition to check |
action_on_fail | statement to execute on failure (e.g. return, return 0, break) |
msg | string literal appended to the log message |
LV_CHECK_ARG_FORMAT_MSG
#define LV_CHECK_ARG_FORMAT_MSG(cond, action_on_fail, format, ...) \
LV_CHECK_ARG_FORMAT_INTERNAL_(cond, #cond, action_on_fail, " " format, __VA_ARGS__)Same as LV_CHECK_ARG but a printf-style message is appended to the log. The message is only used when LV_CHECK_ARG_LOG_MODE is set to VERBOSE.
Example:
LV_CHECK_ARG_FORMAT_MSG(len > 0, return -1, "len=%d", (int)len);| Name | Description |
|---|---|
cond | condition to check |
action_on_fail | statement to execute on failure (e.g. return, return 0, break) |
format | format string literal appended to the log message |
... | arguments of format; at least one is required |
Dependencies
Last updated on