aboutsummaryrefslogtreecommitdiffstats
path: root/examples/test-session.cpp
diff options
context:
space:
mode:
authorPerry Hung <iperry@alum.mit.edu>2010-06-25 21:47:27 -0400
committerPerry Hung <iperry@alum.mit.edu>2010-06-25 21:47:27 -0400
commit2dd4b9db68c15c3be477688b215244c5a5c2ff11 (patch)
tree8bccadfadbd22b4a1e1bae7d8d49da330b6e383c /examples/test-session.cpp
parent6f82321248c2482784ce5a5e0715b62909d1ab76 (diff)
downloadlibrambutan-2dd4b9db68c15c3be477688b215244c5a5c2ff11.tar.gz
librambutan-2dd4b9db68c15c3be477688b215244c5a5c2ff11.zip
Call init() before static constructors
Commit 70a18f96b6d55d23ce58ab40ffb61f172c8f6c73 forces init() to be called before any statically allocated object constructors for the IDE. This adds the change to the examples for users not using the IDE.
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;
}
-