lv_check_arg.h

API reference for lv_check_arg.h

Report on GitHub
Summary

Macros

LV_LIKELY

 
#define LV_LIKELY(x) \
    (x)

LV_UNLIKELY

 
#define LV_UNLIKELY(x) \
    (x)

LV_CHECK_ARG_INTERNAL_

 
#define LV_CHECK_ARG_INTERNAL_(cond, cond_str, action_on_fail, ...) \
    if(LV_UNLIKELY(!(cond))) { \
            LV_LOG_WARN("Check failed: " cond_str " " __VA_ARGS__); \
            action_on_fail; \
        } else {}

Internal macro: checks a condition, logs a warning, and executes the specified action on failure. Do not use directly; use LV_CHECK_ARG instead.

LV_CHECK_ARG

 
#define LV_CHECK_ARG(cond, action_on_fail, ...) \
    LV_CHECK_ARG_INTERNAL_(cond, #cond, action_on_fail, __VA_ARGS__)

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). Additional printf-style arguments are appended to the log message.

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.

Example:

 
LV_CHECK_ARG(ptr != NULL, return, "pointer must not be NULL");
LV_CHECK_ARG(len > 0, return -1, "len=%d", (int)len);
Parameters
NameDescription
condcondition to check
action_on_failstatement to execute on failure (e.g. return, return 0, break)
...optional printf-style format string and arguments appended to the log

Dependencies

How is this guide?

Last updated on

On this page