Skip to content

E0308 Type Mismatch in lvgl (u32 → i32 in Event Constants) #196

@ErickTorresBrownU

Description

@ErickTorresBrownU

UPDATE: I see this repo is deader than my aunt Susan. If you guys need someone to work on the project and revive things, I'd love to step up! Reach out if interested!

Description

When attempting to build an LVGL project using lvgl 0.6.2, the compilation fails with multiple type mismatches (E0308) due to event constants being defined as u32 instead of i32. I did a bit of digging and although the generated type in the code is c_int, the code expects u32 and I believe c_int gets translated as i32 instead, leading to the issue.

This happens inside the support.rs file of lvgl, where match statements expect i32, but the event constants from lvgl-sys are u32.


Steps to Reproduce

  1. Install lvgl via Cargo:
    cargo add lvgl
    cargo build
  2. Compilation fails with the following errors:
    error[E0308]: mismatched types
    --> C:\Users\erick\.cargo\registry\src\index.crates.io-6f17d22bba15001f\lvgl-0.6.2\src\support.rs:154:13
    |
    143 |         const LV_EVENT_PRESS_LOST: u32 = lvgl_sys::lv_event_code_t_LV_EVENT_PRESS_LOST;
    |         ------------------------------ constant defined here
    ...
    151 |         match value {
    |               ----- this expression has type `i32`
    ...
    154 |             LV_EVENT_PRESS_LOST => Ok(Event::PressLost),
    |             ^^^^^^^^^^^^^^^^^^^
    |             |
    |             expected `i32`, found `u32`
    
    (and similar errors for other event constants like LV_EVENT_SHORT_CLICKED, LV_EVENT_CLICKED, LV_EVENT_LONG_PRESSED, etc.)

Expected Behavior

The Rust LVGL bindings should correctly match the types of the event constants, so cargo build should succeed.


Environment

  • OS: Windows 11
  • Rust version: 1.82.0
  • LVGL version: lvgl 0.6.2
  • LVGL-Sys version: lvgl-sys 0.6.2

Thanks in advance for looking into this! 🚀

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions