From 6f82321248c2482784ce5a5e0715b62909d1ab76 Mon Sep 17 00:00:00 2001 From: Perry Hung Date: Fri, 25 Jun 2010 21:42:48 -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. --- main.cpp.example | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'main.cpp.example') 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) { -- cgit v1.2.3