aboutsummaryrefslogtreecommitdiffstats
path: root/examples/debug-dtrrts.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'examples/debug-dtrrts.cpp')
-rw-r--r--examples/debug-dtrrts.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/examples/debug-dtrrts.cpp b/examples/debug-dtrrts.cpp
index c85b342..f9f8b96 100644
--- a/examples/debug-dtrrts.cpp
+++ b/examples/debug-dtrrts.cpp
@@ -30,9 +30,14 @@ void loop() {
Serial2.println(usbGetRTS(), DEC);
}
-
-int main(void) {
+// Force init to be called *first*, i.e. before static object allocation.
+// Otherwise, statically allocated object that need libmaple may fail.
+ __attribute__(( constructor )) void premain() {
init();
+}
+
+int main(void)
+{
setup();
while (1) {
@@ -40,3 +45,4 @@ int main(void) {
}
return 0;
}
+