aboutsummaryrefslogtreecommitdiffstats
path: root/examples/qa-slave-shield.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/qa-slave-shield.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/qa-slave-shield.cpp')
-rw-r--r--examples/qa-slave-shield.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/examples/qa-slave-shield.cpp b/examples/qa-slave-shield.cpp
index fcee9cf..b395cca 100644
--- a/examples/qa-slave-shield.cpp
+++ b/examples/qa-slave-shield.cpp
@@ -37,9 +37,14 @@ void loop() {
}
}
-
-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) {
@@ -47,3 +52,4 @@ int main(void) {
}
return 0;
}
+