Skip to content

Commit cb3bce5

Browse files
committed
please build i need this
1 parent 9a8a3f7 commit cb3bce5

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

pybricks/experimental/pb_module_experimental.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
#include "pybricks/experimental/odometry.h"
88

9-
// Fallback for STATIC if needed
109
#ifndef STATIC
1110
#define STATIC static
1211
#endif
@@ -24,13 +23,20 @@ STATIC mp_obj_t experimental_odometry_benchmark(size_t n_args, const mp_obj_t *a
2423
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(experimental_odometry_benchmark_obj, 5, 5, experimental_odometry_benchmark);
2524

2625
// 2. The Globals Table
27-
// The Pybricks generator looks for a variable named: <filename_prefix>_globals
2826
STATIC const mp_rom_map_elem_t pb_module_experimental_globals_table[] = {
2927
{ MP_ROM_QSTR(MP_QSTR_odometry_benchmark), MP_ROM_PTR(&experimental_odometry_benchmark_obj) },
3028
};
31-
STATIC MP_DEFINE_CONST_DICT(pb_module_experimental_globals, pb_module_experimental_globals_table);
3229

33-
// NOTE: DO NOT define 'const mp_obj_module_t pb_module_experimental' here.
34-
// The build system generates it in build/genhdr/moduledefs.h automatically.
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+
};
3541

3642
#endif // PYBRICKS_PY_EXPERIMENTAL

0 commit comments

Comments
 (0)