studio icon indicating copy to clipboard operation
studio copied to clipboard

Var types incompatible in screen tick

Open Luke-Shepp opened this issue 2 months ago • 1 comments

My generated screens.c looks something like this;

void tick_screen_main() {
    [...trimmed...]
    {
        const char *new_val = get_var_speed();
        const char *cur_val = lv_label_get_text(objects.obj2);
        if (strcmp(new_val, cur_val) != 0) {
            tick_value_change_obj = objects.obj2;
            lv_label_set_text(objects.obj2, new_val);
            tick_value_change_obj = NULL;
        }
    }
    [....trimmed....]
}

get_var_speed is defined in the generated vars.h as:

extern float get_var_speed();

That is because I have chosen it to be a float value in the UI:

Screenshot 2024-04-22 at 19 16 43

Due to the type mismatch, the error on build is:

ui/screens.c: In function 'tick_screen_main':
ui/screens.c:166:31: error: incompatible types when initializing type 'const char *' using type 'float'
  166 |         const char *new_val = get_var_speed();
      |                               ^~~~~~~~~~~~~
ui/screens.c: In function 'tick_screen_settings':

There's another warning for another variable, but it's not a hard error this one:

ui/screens.c:292:31: warning: initialization of 'const char *' from 'int32_t' {aka 'long int'} makes pointer from integer without a cast [-Wint-conversion]
  292 |         const char *new_val = get_var_wifi_state();
      |                               ^~~~~~~~~~~~~~~~~~
make: *** [ui/screens.o] Error 1

Luke-Shepp avatar Apr 22 '24 18:04 Luke-Shepp