aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--main.cpp.example9
1 files changed, 7 insertions, 2 deletions
diff --git a/main.cpp.example b/main.cpp.example
index 0b0c6c7..1032733 100644
--- a/main.cpp.example
+++ b/main.cpp.example
@@ -31,9 +31,14 @@ void loop() {
delay(100);
}
-
-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) {