From 2dd4b9db68c15c3be477688b215244c5a5c2ff11 Mon Sep 17 00:00:00 2001 From: Perry Hung Date: Fri, 25 Jun 2010 21:47:27 -0400 Subject: 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. --- examples/qa-slave-shield.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'examples/qa-slave-shield.cpp') 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; } + -- cgit v1.2.3