On Wio terminal C++ constructors for static objects are called twice. I don’t have debugger so I don’t know where they get called for the fist time but the second time they get called from main
function that calls __libc_init_array
that cause second call. Simple program to show this behavior:
#include <Arduino.h>
int init_called = 0;
class Test {
public:
Test() {
init_called++;
}
};
Test test;
void setup() {
Serial.begin(115200);
}
void loop() {
Serial.print("init_called ");
Serial.println(init_called);
delay(1000);
}
It prints “init_called 2” to serial. It causes problems for programs that relay on normal C++ behavior and register static objects from constructors. Could you please fix it?