1010#define STATIC static
1111#endif
1212
13- // 1. The function logic
13+ // 1. The actual function logic
1414STATIC mp_obj_t experimental_odometry_benchmark (size_t n_args , const mp_obj_t * args ) {
1515 int num_iters = mp_obj_get_int (args [0 ]);
1616 float wheel_circ = mp_obj_get_float (args [1 ]);
@@ -22,21 +22,12 @@ STATIC mp_obj_t experimental_odometry_benchmark(size_t n_args, const mp_obj_t *a
2222}
2323STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN (experimental_odometry_benchmark_obj , 5 , 5 , experimental_odometry_benchmark );
2424
25- // 2. The Globals Table
25+ // 2. The Globals Table - the system looks for the name "<filename>_globals"
26+ // Since your file is pb_module_experimental.c, it looks for pb_module_experimental_globals
2627STATIC const mp_rom_map_elem_t pb_module_experimental_globals_table [] = {
2728 { MP_ROM_QSTR (MP_QSTR_odometry_benchmark ), MP_ROM_PTR (& experimental_odometry_benchmark_obj ) },
2829};
29-
30- // 3. THE FIX: Define the dict WITHOUT 'STATIC'.
31- // This makes it a globally visible symbol that the linker can grab,
32- // and stops the compiler from complaining that it's "unused" inside this file.
33- MP_DEFINE_CONST_DICT (pb_module_experimental_globals , pb_module_experimental_globals_table );
34-
35- // We define the module struct here so the linker finds it.
36- // We DO NOT use STATIC, and we DO NOT use MP_REGISTER_MODULE.
37- const mp_obj_module_t pb_module_experimental = {
38- .base = { & mp_type_module },
39- .globals = (mp_obj_dict_t * )& pb_module_experimental_globals ,
40- };
30+ // This is the specific symbol the linker is clashing on - we keep it STATIC here.
31+ STATIC MP_DEFINE_CONST_DICT (pb_module_experimental_globals , pb_module_experimental_globals_table );
4132
4233#endif // PYBRICKS_PY_EXPERIMENTAL
0 commit comments