aboutsummaryrefslogtreecommitdiffstats
path: root/examples/blinky.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'examples/blinky.cpp')
-rw-r--r--examples/blinky.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/examples/blinky.cpp b/examples/blinky.cpp
index e156bf2..b037a1f 100644
--- a/examples/blinky.cpp
+++ b/examples/blinky.cpp
@@ -42,8 +42,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) {