Skip to content

Commit a83e6e0

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/Arduino#2229 arduino/Arduino#1919
1 parent a2748cf commit a83e6e0

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

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);

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)