You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Arduino Developers
In general, library code (and sketch code) should not call high-level Arduino functions like pinMode() from constructors, because constructors get called before init(), right?
SoftwareSerial does this :-(
BillW / WestfW
bob cousins
unread,
Apr 26, 2015, 5:22:44 AM4/26/15
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to devel...@arduino.cc
An awful lot of libraries do the same thing!
The Arduino core has a special bodge to init the API before constructors are called, but this is a bad habit to encourage and is a pain if using third-party cores which do a more normal initialization.
In general, a constructor should not have dependencies on any external code.
William Westfield
unread,
Apr 26, 2015, 8:05:41 PM4/26/15
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to devel...@arduino.cc
> The Arduino core has a special bodge to init the API before constructors are called
It does? Where is that?
BillW
bob cousins
unread,
Apr 27, 2015, 3:33:31 PM4/27/15
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to devel...@arduino.cc
I should rephrase that to say the Due core has a bodge:
// Arduino: we must setup hardware before doing this //__libc_init_array();
/* Branch to main function */ main();
/* Infinite loop */ while (1);
main() does setup then calls libc_init_array().
I have never looked at the AVR startup code, but I assumed it would be similar - maybe not. I'm not even sure where the AVR startup code is, I guess it is baked into toolchain already.