Wio Terminal: constructors for static objects are called twice

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?

I happened to have the same problem yesterday. we’ll fix it as soon as we can. Thank you for your feedback. @dup

1 Like

hi @dup
This problem has been fixed in commit https://github.com/Seeed-Studio/ArduinoCore-samd/commit/8ed9028ddb64b9f321e6062effed489d77c3a50d (Release 1.7.7)
So you can simply update the samd arduino core to latest version.

1 Like