# lv_check_arg.h (/api/misc/lv_check_arg_h)



<ApiSummary macros="4" />

Macros [#macros]

<ApiMember kind="macro" name="LV_LIKELY" file="misc/lv_check_arg.h" line="28" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_check_arg.h#L28">
  LV_LIKELY [#lv_likely]

  ```c title=" " lineNumbers=1
  #define LV_LIKELY(x) \
      (x)
  ```
</ApiMember>

<ApiMember kind="macro" name="LV_UNLIKELY" file="misc/lv_check_arg.h" line="29" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_check_arg.h#L29">
  LV_UNLIKELY [#lv_unlikely]

  ```c title=" " lineNumbers=1
  #define LV_UNLIKELY(x) \
      (x)
  ```
</ApiMember>

<ApiMember kind="macro" name="LV_CHECK_ARG_INTERNAL_" file="misc/lv_check_arg.h" line="67" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_check_arg.h#L67">
  LV_CHECK_ARG_INTERNAL_ [#lv_check_arg_internal_]

  ```c title=" " lineNumbers=1
  #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.
</ApiMember>

<ApiMember kind="macro" name="LV_CHECK_ARG" file="misc/lv_check_arg.h" line="101" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_check_arg.h#L101">
  LV_CHECK_ARG [#lv_check_arg]

  ```c title=" " lineNumbers=1
  #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:

  ```c title=" " lineNumbers=1
  LV_CHECK_ARG(ptr != NULL, return, "pointer must not be NULL");
  LV_CHECK_ARG(len > 0, return -1, "len=%d", (int)len);
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name             | Description                                                           |
  | ---------------- | --------------------------------------------------------------------- |
  | `cond`           | condition to check                                                    |
  | `action_on_fail` | statement to execute on failure (e.g. `return`, `return 0`, `break`)  |
  | `...`            | optional printf-style format string and arguments appended to the log |
</ApiMember>

Dependencies [#dependencies]

<FileIncludes includes="[&#x22;lv_conf_internal.h&#x22;, &#x22;lv_log.h&#x22;, &#x22;lv_assert.h&#x22;]" transitiveIncludes="[&#x22;lv_conf_kconfig.h&#x22;, &#x22;lv_mem.h&#x22;, &#x22;lv_string.h&#x22;, &#x22;lv_types.h&#x22;]" />
