From b0a8d5d6f47f30637b1132bc9fd7a336eec3beaa Mon Sep 17 00:00:00 2001 From: Abel Stuker Date: Mon, 27 Apr 2026 23:08:20 +0200 Subject: [PATCH 1/2] Fix global init designators and their order --- src/Primitives/arduino.cpp | 11 +++++++---- src/Primitives/emulated.cpp | 11 +++++++---- src/Primitives/idf.cpp | 11 +++++++---- src/Primitives/zephyr.cpp | 11 +++++++---- src/WARDuino/internals.h | 10 +++++----- 5 files changed, 33 insertions(+), 21 deletions(-) diff --git a/src/Primitives/arduino.cpp b/src/Primitives/arduino.cpp index 80329573..300958b2 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##_g = {.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..792fa61b 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##_g = {.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..f10de6e1 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##_g = {.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..6d6be4cd 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##_g = {.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 { From f5b44fb010156acf5f46d68f66ca5bb4d8a891c1 Mon Sep 17 00:00:00 2001 From: Abel Stuker Date: Mon, 27 Apr 2026 23:20:51 +0200 Subject: [PATCH 2/2] Fix def_glob global name --- src/Primitives/arduino.cpp | 10 +++++----- src/Primitives/emulated.cpp | 10 +++++----- src/Primitives/idf.cpp | 10 +++++----- src/Primitives/zephyr.cpp | 10 +++++----- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/Primitives/arduino.cpp b/src/Primitives/arduino.cpp index 300958b2..93e4e8d3 100644 --- a/src/Primitives/arduino.cpp +++ b/src/Primitives/arduino.cpp @@ -136,11 +136,11 @@ int global_index = 0; #define def_glob(name, type, mut, init_val) \ StackValue name##_sv = {.value_type = type, .value = {init_val}}; \ - Global name##_g = {.export_name = nullptr, \ - .import_module = nullptr, \ - .import_field = #name, \ - .mutability = mut, \ - .value = &name##_sv}; + 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 792fa61b..d7763f2d 100644 --- a/src/Primitives/emulated.cpp +++ b/src/Primitives/emulated.cpp @@ -35,11 +35,11 @@ double sensor_emu = 0; #define def_glob(name, type, mut, init_val) \ StackValue name##_sv = {.value_type = type, .value = {init_val}}; \ - Global name##_g = {.export_name = nullptr, \ - .import_module = nullptr, \ - .import_field = #name, \ - .mutability = mut, \ - .value = &name##_sv}; + 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 f10de6e1..67fb682b 100644 --- a/src/Primitives/idf.cpp +++ b/src/Primitives/idf.cpp @@ -34,11 +34,11 @@ int global_index = 0; #define def_glob(name, type, mut, init_val) \ StackValue name##_sv = {.value_type = type, .value = {init_val}}; \ - Global name##_g = {.export_name = nullptr, \ - .import_module = nullptr, \ - .import_field = #name, \ - .mutability = mut, \ - .value = &name##_sv}; + 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 6d6be4cd..471fa0b4 100644 --- a/src/Primitives/zephyr.cpp +++ b/src/Primitives/zephyr.cpp @@ -42,11 +42,11 @@ int global_index = 0; #define def_glob(name, type, mut, init_val) \ StackValue name##_sv = {.value_type = type, .value = {init_val}}; \ - Global name##_g = {.export_name = nullptr, \ - .import_module = nullptr, \ - .import_field = #name, \ - .mutability = mut, \ - .value = &name##_sv}; + Global name = {.export_name = nullptr, \ + .import_module = nullptr, \ + .import_field = #name, \ + .mutability = mut, \ + .value = &name##_sv}; #define install_global(global_name) \ { \