Skip to content

Make init() run before C++ static initializers #5592

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion hardware/arduino/avr/cores/arduino/wiring.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,10 @@ void delayMicroseconds(unsigned int us)
// return = 4 cycles
}

void init()
//http://www.atmel.com/webdoc/AVRLibcReferenceManual/mem_sections_1sec_dot_init.html
// init5 is after .data, but before C++ initialization - perfect for hardware setup
void _do_setup(void) __attribute__ ((naked, used, section (".init5")));
void _do_setup()
{
// this needs to be called before setup() or some functions won't
// work there
Expand Down Expand Up @@ -390,3 +393,6 @@ void init()
UCSR0B = 0;
#endif
}

// for backwards compatibility
void init() {}