aboutsummaryrefslogtreecommitdiffstats
path: root/main.cpp.example
diff options
context:
space:
mode:
authorPerry Hung <iperry@alum.mit.edu>2010-06-25 21:42:48 -0400
committerPerry Hung <iperry@alum.mit.edu>2010-06-25 21:42:48 -0400
commit6f82321248c2482784ce5a5e0715b62909d1ab76 (patch)
tree3644380dd02503eb1316c38ac32f5fc1a9dcb1c6 /main.cpp.example
parent2c043efb66416f3d5cd85f0939054766082354de (diff)
downloadlibrambutan-6f82321248c2482784ce5a5e0715b62909d1ab76.tar.gz
librambutan-6f82321248c2482784ce5a5e0715b62909d1ab76.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 'main.cpp.example')
-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) {