Skip to content

Commit 18d8875

Browse files
authored
Merge pull request #129 from fpistm/use_STL
Use STLc++ instead of macro
2 parents c0222d6 + 2f9e8a3 commit 18d8875

File tree

2 files changed

+21
-24
lines changed

2 files changed

+21
-24
lines changed

cores/arduino/wiring_constants.h

+19-22
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,26 @@
1919
#ifndef _WIRING_CONSTANTS_
2020
#define _WIRING_CONSTANTS_
2121

22+
#include <stdbool.h>
23+
2224
#ifdef __cplusplus
23-
extern "C"{
24-
#endif // __cplusplus
25+
#include <algorithm>
26+
using std::min;
27+
using std::max;
28+
#else // C
29+
#ifndef abs
30+
#define abs(x) ((x)>0?(x):-(x))
31+
#endif // abs
2532

26-
#include <stdbool.h>
33+
#ifndef min
34+
#define min(a,b) ((a)<(b)?(a):(b))
35+
#endif // min
36+
37+
#ifndef max
38+
#define max(a,b) ((a)>(b)?(a):(b))
39+
#endif // max
40+
41+
#endif // __cplusplus
2742

2843
#define HIGH 0x1
2944
#define LOW 0x0
@@ -57,22 +72,8 @@ enum BitOrder {
5772
#define DEFAULT 1
5873
#define EXTERNAL 0
5974

60-
// undefine stdlib's abs if encountered
61-
#ifdef abs
62-
#undef abs
63-
#endif // abs
64-
65-
#ifndef min
66-
#define min(a,b) ((a)<(b)?(a):(b))
67-
#endif // min
68-
69-
#ifndef max
70-
#define max(a,b) ((a)>(b)?(a):(b))
71-
#endif // max
72-
73-
#define abs(x) ((x)>0?(x):-(x))
7475
#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))
75-
#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
76+
7677
#define radians(deg) ((deg)*DEG_TO_RAD)
7778
#define degrees(rad) ((rad)*RAD_TO_DEG)
7879
#define sq(x) ((x)*(x))
@@ -106,8 +107,4 @@ typedef bool boolean ;
106107

107108
typedef uint8_t byte ;
108109

109-
#ifdef __cplusplus
110-
} // extern "C"
111-
#endif // __cplusplus
112-
113110
#endif /* _WIRING_CONSTANTS_ */

platform.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ compiler.c.elf.flags=-mthumb {build.flags.optimize} {build.flags.ldspecs} -Wl,--
2828
compiler.S.cmd=arm-none-eabi-gcc
2929
compiler.S.flags=-mthumb -c -x assembler-with-cpp {compiler.stm.extra_include}
3030
compiler.cpp.cmd=arm-none-eabi-g++
31-
compiler.cpp.flags=-mthumb -c {build.flags.optimize} {compiler.warning_flags} -std=gnu++11 -ffunction-sections -fdata-sections -nostdlib -fno-threadsafe-statics --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -Dprintf=iprintf -MMD {compiler.stm.extra_include}
31+
compiler.cpp.flags=-mthumb -c {build.flags.optimize} {compiler.warning_flags} -std=gnu++11 -ffunction-sections -fdata-sections -nostdlib -fno-threadsafe-statics --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD {compiler.stm.extra_include}
3232
compiler.ar.cmd=arm-none-eabi-gcc-ar
3333
compiler.ar.flags=rcs
3434
compiler.objcopy.cmd=arm-none-eabi-objcopy
@@ -85,7 +85,7 @@ recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -mcpu={b
8585
recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}"
8686

8787
## Combine gc-sections, archives, and objects
88-
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.flags} -mcpu={build.mcu} -DF_CPU={build.f_cpu} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" {compiler.c.elf.extra_flags} {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" "-L{build.path}" -Wl,--start-group {object_files} {compiler.arm.cmsis.ldflags} -Wl,--whole-archive "{archive_file_path}" -Wl,--no-whole-archive -lc -Wl,--end-group -lm -lgcc --specs=nano.specs
88+
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.flags} -mcpu={build.mcu} -DF_CPU={build.f_cpu} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" {compiler.c.elf.extra_flags} {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" "-L{build.path}" -Wl,--start-group {object_files} {compiler.arm.cmsis.ldflags} -Wl,--whole-archive "{archive_file_path}" -Wl,--no-whole-archive -lc -Wl,--end-group -lm -lgcc -lstdc++ --specs=nano.specs
8989

9090

9191
## Create output (.bin file)

0 commit comments

Comments
 (0)