aboutsummaryrefslogtreecommitdiffstats
path: root/examples/test-session.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'examples/test-session.cpp')
-rw-r--r--examples/test-session.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/examples/test-session.cpp b/examples/test-session.cpp
index 4f09591..9885ab3 100644
--- a/examples/test-session.cpp
+++ b/examples/test-session.cpp
@@ -555,8 +555,14 @@ void do_fast_gpio(void) {
gpio_write_bit(GPIOB_BASE, 5, 1); gpio_write_bit(GPIOB_BASE, 5, 0);
}
-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) {
@@ -564,4 +570,3 @@ int main(void) {
}
return 0;
}
-