# lv_assert.h (/api/misc/lv_assert_h)



<ApiSummary macros="6" />

Macros [#macros]

<ApiMember kind="macro" name="LV_ASSERT" file="misc/lv_assert.h" line="37" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_assert.h#L37">
  LV_ASSERT [#lv_assert]

  ```c title=" " lineNumbers=1
  #define LV_ASSERT(expr) \
      do { \
              if(!(expr)) { \
                  LV_LOG_ERROR("Asserted at expression: %s", #expr); \
                  LV_ASSERT_HANDLER \
              } \
          } while(0)
  ```
</ApiMember>

<ApiMember kind="macro" name="LV_ASSERT_MSG" file="misc/lv_assert.h" line="45" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_assert.h#L45">
  LV_ASSERT_MSG [#lv_assert_msg]

  ```c title=" " lineNumbers=1
  #define LV_ASSERT_MSG(expr, msg) \
      do { \
              if(!(expr)) { \
                  LV_LOG_ERROR("Asserted at expression: %s (%s)", #expr, msg); \
                  LV_ASSERT_HANDLER \
              } \
          } while(0)
  ```
</ApiMember>

<ApiMember kind="macro" name="LV_ASSERT_FORMAT_MSG" file="misc/lv_assert.h" line="53" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_assert.h#L53">
  LV_ASSERT_FORMAT_MSG [#lv_assert_format_msg]

  ```c title=" " lineNumbers=1
  #define LV_ASSERT_FORMAT_MSG(expr, format, ...) \
      do { \
              if(!(expr)) { \
                  LV_LOG_ERROR("Asserted at expression: %s " format , #expr, __VA_ARGS__); \
                  LV_ASSERT_HANDLER \
              } \
          } while(0)
  ```
</ApiMember>

<ApiMember kind="macro" name="LV_ASSERT_NULL" file="misc/lv_assert.h" line="66" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_assert.h#L66">
  LV_ASSERT_NULL [#lv_assert_null]

  ```c title=" " lineNumbers=1
  #define LV_ASSERT_NULL(p) \
      LV_ASSERT_MSG(p != NULL, "NULL pointer");
  ```
</ApiMember>

<ApiMember kind="macro" name="LV_ASSERT_MALLOC" file="misc/lv_assert.h" line="72" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_assert.h#L72">
  LV_ASSERT_MALLOC [#lv_assert_malloc]

  ```c title=" " lineNumbers=1
  #define LV_ASSERT_MALLOC(p) \
      LV_ASSERT_MSG(p != NULL, "Out of memory");
  ```
</ApiMember>

<ApiMember kind="macro" name="LV_ASSERT_MEM_INTEGRITY" file="misc/lv_assert.h" line="78" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/misc/lv_assert.h#L78">
  LV_ASSERT_MEM_INTEGRITY [#lv_assert_mem_integrity]

  ```c title=" " lineNumbers=1
  #define LV_ASSERT_MEM_INTEGRITY() \
      LV_ASSERT_MSG(lv_mem_test() == LV_RESULT_OK, "Memory integrity error");
  ```
</ApiMember>

Dependencies [#dependencies]

<FileIncludes includes="[&#x22;lv_conf_internal.h&#x22;, &#x22;lv_log.h&#x22;, &#x22;lv_mem.h&#x22;, &#x22;stdint.h&#x22;]" includedBy="[&#x22;lv_obj.h&#x22;, &#x22;lv_nanovg_utils.h&#x22;, &#x22;lv_check_arg.h&#x22;, &#x22;lv_color.h&#x22;, &#x22;lv_color_op.h&#x22;, &#x22;lv_rb.h&#x22;, &#x22;lv_style.h&#x22;]" transitiveIncludes="[&#x22;lv_conf_kconfig.h&#x22;, &#x22;lv_string.h&#x22;, &#x22;lv_types.h&#x22;]" />
