diff --git a/src/Primitives/arduino.cpp b/src/Primitives/arduino.cpp index 80329573..93e4e8d3 100644 --- a/src/Primitives/arduino.cpp +++ b/src/Primitives/arduino.cpp @@ -134,10 +134,13 @@ int resolve_isr(int pin) { int global_index = 0; -#define def_glob(name, type, mut, init_value) \ - StackValue name##_sv{.value_type = type, init_value}; \ - Global name = { \ - .mutability = mut, .import_field = #name, .value = &name##_sv}; +#define def_glob(name, type, mut, init_val) \ + StackValue name##_sv = {.value_type = type, .value = {init_val}}; \ + Global name = {.export_name = nullptr, \ + .import_module = nullptr, \ + .import_field = #name, \ + .mutability = mut, \ + .value = &name##_sv}; #define install_global(global_name) \ { \ diff --git a/src/Primitives/emulated.cpp b/src/Primitives/emulated.cpp index 94bccf83..d7763f2d 100644 --- a/src/Primitives/emulated.cpp +++ b/src/Primitives/emulated.cpp @@ -33,10 +33,13 @@ int global_index = 0; double sensor_emu = 0; -#define def_glob(name, type, mut, init_value) \ - StackValue name##_sv{.value_type = type, init_value}; \ - Global name = { \ - .mutability = mut, .import_field = #name, .value = &name##_sv}; +#define def_glob(name, type, mut, init_val) \ + StackValue name##_sv = {.value_type = type, .value = {init_val}}; \ + Global name = {.export_name = nullptr, \ + .import_module = nullptr, \ + .import_field = #name, \ + .mutability = mut, \ + .value = &name##_sv}; #define install_global(global_name) \ { \ diff --git a/src/Primitives/idf.cpp b/src/Primitives/idf.cpp index 09ea1d8d..67fb682b 100644 --- a/src/Primitives/idf.cpp +++ b/src/Primitives/idf.cpp @@ -32,10 +32,13 @@ int global_index = 0; -#define def_glob(name, type, mut, init_value) \ - StackValue name##_sv{.value_type = type, init_value}; \ - Global name = { \ - .mutability = mut, .import_field = #name, .value = &name##_sv}; +#define def_glob(name, type, mut, init_val) \ + StackValue name##_sv = {.value_type = type, .value = {init_val}}; \ + Global name = {.export_name = nullptr, \ + .import_module = nullptr, \ + .import_field = #name, \ + .mutability = mut, \ + .value = &name##_sv}; #define install_global(global_name) \ { \ diff --git a/src/Primitives/zephyr.cpp b/src/Primitives/zephyr.cpp index cb02d67f..471fa0b4 100644 --- a/src/Primitives/zephyr.cpp +++ b/src/Primitives/zephyr.cpp @@ -40,10 +40,13 @@ int global_index = 0; -#define def_glob(name, type, mut, init_value) \ - StackValue name##_sv{.value_type = type, init_value}; \ - Global name = { \ - .mutability = mut, .import_field = #name, .value = &name##_sv}; +#define def_glob(name, type, mut, init_val) \ + StackValue name##_sv = {.value_type = type, .value = {init_val}}; \ + Global name = {.export_name = nullptr, \ + .import_module = nullptr, \ + .import_field = #name, \ + .mutability = mut, \ + .value = &name##_sv}; #define install_global(global_name) \ { \ diff --git a/src/WARDuino/internals.h b/src/WARDuino/internals.h index c13b4fd0..8e09d8c1 100644 --- a/src/WARDuino/internals.h +++ b/src/WARDuino/internals.h @@ -112,11 +112,11 @@ typedef struct Memory { } Memory; typedef struct Global { - char *export_name; // export name of the global - char *import_module; // import module name - char *import_field; // import field name - bool mutability; // 0: immutable, 1: mutable - StackValue *value; // current value + char *export_name; // export name of the global + char *import_module; // import module name + const char *import_field; // import field name + bool mutability; // 0: immutable, 1: mutable + StackValue *value; // current value } Global; typedef struct Options {