Skip to content

Commit 1bbcb2f

Browse files
Chris--Acmaglie
authored andcommitted
Added replacement stub for cstdlib atexit() funciton.
This is an empty stub to simply allow use of complex types with a non global static lifetime. For more complex handling the function 'atexit' can be redefined in user code. For more information see: arduino#2229 arduino#1919
1 parent e71bbf6 commit 1bbcb2f

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

build/shared/revisions.txt

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ ARDUINO 1.0.6 - not yet released
55
* avr: Improved USB-CDC write speed (Justin Rajewski)
66
* avr: Improved USB-CDC read code (Paul Brook)
77
* avr: Fixed race condition in USB-CDC transmit (Paul Brook)
8+
* avr: Added replacement stub for cstdlib atexit() funciton (Christopher Andrews)
89
* Fixed wrong NULL pointer handling in Stream class (Amulya Kumar Sahoo)
910
* Backported String class from IDE 1.5.x (Matt Jenkins)
1011
* Backported Print class from IDE 1.5.x

hardware/arduino/cores/arduino/Arduino.h

+2
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ typedef uint8_t byte;
115115
void init(void);
116116
void initVariant(void);
117117

118+
int atexit(void (*func)()) __attribute__((weak));
119+
118120
void pinMode(uint8_t, uint8_t);
119121
void digitalWrite(uint8_t, uint8_t);
120122
int digitalRead(uint8_t);

hardware/arduino/cores/arduino/main.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919

2020
#include <Arduino.h>
2121

22+
//Declared weak in Arduino.h to allow user redefinitions.
23+
int atexit(void (*func)()) { return 0; }
24+
2225
// Weak empty variant initialization function.
2326
// May be redefined by variant files.
2427
void initVariant() __attribute__((weak));

0 commit comments

Comments
 (0)