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

Two-dimensional array binding type problem #302

Open
onecoolx opened this issue Nov 6, 2023 · 1 comment
Open

Two-dimensional array binding type problem #302

onecoolx opened this issue Nov 6, 2023 · 1 comment

Comments

@onecoolx
Copy link

onecoolx commented Nov 6, 2023

I'm adding matrix type to LVGL project. I added a matrix type and its c code declaration is:

typedef struct {
     float m[3][3];
} lv_matrix_t;

But A type error occurred when generating the binding code of micropython. An error similar to the following:

build-standard/lvgl/lv_mpy.c:25340:28: error: expected identifier or ‘(’ before ‘[’ token
25340 | GENMPY_UNUSED STATIC float [3] *mp_arr_to_float___3____3__(mp_obj_t mp_arr)
      |                            ^
build-standard/lvgl/lv_mpy.c:25356:70: error: expected ‘;’, ‘,’ or ‘)’ before ‘*’ token
25356 | GENMPY_UNUSED STATIC mp_obj_t mp_arr_from_float___3____3__(float [3] *arr)
      |                                                                      ^
build-standard/lvgl/lv_mpy.c: In function ‘mp_lv_matrix_t_attr’:
build-standard/lvgl/lv_mpy.c:25397:39: error: implicit declaration of function ‘mp_arr_from_float___3____3__’; did you mean ‘mp_arr_from_float___3__’? [-Werror=implicit-function-declaration]
25397 |             case MP_QSTR_m: dest[0] = mp_arr_from_float___3____3__(data->m); break; // converting from float [3][3];
      |                                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                       mp_arr_from_float___3__
build-standard/lvgl/lv_mpy.c:25397:37: error: assignment to ‘mp_obj_t’ {aka ‘void *’} from ‘int’ makes pointer from integer without a cast [-Werror=int-conversion]
25397 |             case MP_QSTR_m: dest[0] = mp_arr_from_float___3____3__(data->m); break; // converting from float [3][3];
      |

Its type becomes float[3] * , Is this a bug?

@andrewleech
Copy link

I ran into this same issue today when trying to enable LV_USE_VECTOR_GRAPHIC in lv_conf.h.
The python bindings generator doesn't currently support multi-dim arrays at all. I started trying to add support in andrewleech@ac16d02 but haven't had time to finish it yet.

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

2 participants