Skip to content

Commit 972a443

Browse files
author
noasakurajin
committed
adding another workaround for arduino
This should get rid of basically all errors caused by stupid C macros. Because of the the unit system should work on the AVR boards. It also causes it to provide std::size_t, std::max and std::abs.
1 parent d4dcc68 commit 972a443

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

generic/include/unit_t.hpp

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,32 @@
11
#pragma once
22

3-
#include <cstddef>
4-
#include <cmath>
5-
#include <algorithm>
3+
#if __has_include(<cstddef>)
4+
#include <cstddef>
5+
#else
6+
#ifdef abs
7+
#undef abs
8+
#endif
9+
10+
#ifdef max
11+
#undef max
12+
#endif
13+
14+
namespace std{
15+
using size_t = unsigned int;
16+
17+
template <typename T>
18+
T abs(T var){
19+
return var > 0 ? var : -var;
20+
}
21+
22+
template <typename T>
23+
T max(T v1, T v2){
24+
return v1 > v2 ? v1 : v2;
25+
}
26+
}
27+
#endif
28+
29+
630

731
namespace sakurajin{
832
namespace unit_system{

0 commit comments

Comments
 (0)