Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error: expected primary-expression before ‘.’ token when compiling as C++ #11

Open
MorsMortium opened this issue Sep 4, 2024 · 1 comment

Comments

@MorsMortium
Copy link

https://forum.lvgl.io/t/using-images-in-lvgl-getting-error-expected-primary-expression-before-token/4983

This issue occured to me, when using the converter and then compiling the resulting code in a c++ project. The solution is written in the post too:

If you put the fields in the exact order as they are defined in the structs it should also work in cpp:

const lv_img_dsc_t SoS_Skull = {
.header.cf = LV_IMG_CF_RAW_ALPHA,
.header.always_zero = 0,
.header.reserved = 0,
.header.w = 191,
.header.h = 237,
.data_size = 11505,
.data = SoS_Skull_map,
};

Could the converter order the fields this way?

@MorsMortium
Copy link
Author

After some testing, I've found two different orderings, that worked:

const lv_img_dsc_t Window = {
  .header = {
    .cf = LV_IMG_CF_TRUE_COLOR,
    .always_zero = 0,
    .reserved = 2,
    .w = 240,
    .h = 240,
  },
  .data_size = 57600 * LV_COLOR_SIZE / 8,
  .data = Window_map,
};

and

const lv_img_dsc_t Window = {
  {
    LV_IMG_CF_TRUE_COLOR,
    0,
    2,
    240,
    240,
  },
  57600 * LV_COLOR_SIZE / 8,
  Window_map,
};

The order matters, for both of them. If this isn't desirable for the default behaviour, it could be set with some flag

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant