SensorLib 0.5.0
Multi-platform sensor driver library for Arduino, PlatformIO, and ESP-IDF
Loading...
Searching...
No Matches
SensorLibExceptionFix.cpp
Go to the documentation of this file.
1
13// Only activate this fix for Arduino nRF52 platforms with C++ exceptions disabled
14#if defined(ARDUINO_ARCH_NRF52) && !defined(__cpp_exceptions)
15
16#include <assert.h>
17#include <cstdlib>
18#include <new>
19
20#pragma GCC diagnostic push
21#pragma GCC diagnostic ignored "-Wpedantic"
22
23namespace std
24{
34__attribute__((weak))
35void __throw_bad_function_call()
36{
37 assert(false && "Attempted to call an empty std::function");
38}
39
48__attribute__((weak))
49void __throw_length_error(char const* msg)
50{
51 // Use assert to indicate programming error
52 assert(false && msg);
53}
54
63__attribute__((weak))
64void __throw_out_of_range(char const* msg)
65{
66 assert(false && msg);
67}
68
69const nothrow_t nothrow{};
70}
71
81__attribute__((weak))
82void* operator new (std::size_t size, const std::nothrow_t &) noexcept
83{
84 return malloc(size);
85}
86
95__attribute__((weak))
96void operator delete (void* ptr, const std::nothrow_t &) noexcept
97{
98 free(ptr);
99}
100
110__attribute__((weak))
111void* operator new[](std::size_t size, const std::nothrow_t &) noexcept
112{
113 return malloc(size);
114}
115
124__attribute__((weak))
125void operator delete[](void* ptr, const std::nothrow_t &) noexcept
126{
127 free(ptr);
128}
129#pragma GCC diagnostic pop
130
131#endif // defined(ARDUINO_ARCH_NRF52) && !defined(__cpp_exceptions)
__attribute__((weak)) void setupPower()