diff --git a/cores/arduino/wiring_constants.h b/cores/arduino/wiring_constants.h index 1fede61f63..312cabde28 100644 --- a/cores/arduino/wiring_constants.h +++ b/cores/arduino/wiring_constants.h @@ -19,11 +19,26 @@ #ifndef _WIRING_CONSTANTS_ #define _WIRING_CONSTANTS_ +#include <stdbool.h> + #ifdef __cplusplus -extern "C"{ -#endif // __cplusplus +#include <algorithm> +using std::min; +using std::max; +#else // C +#ifndef abs +#define abs(x) ((x)>0?(x):-(x)) +#endif // abs -#include <stdbool.h> +#ifndef min +#define min(a,b) ((a)<(b)?(a):(b)) +#endif // min + +#ifndef max +#define max(a,b) ((a)>(b)?(a):(b)) +#endif // max + +#endif // __cplusplus #define HIGH 0x1 #define LOW 0x0 @@ -57,22 +72,8 @@ enum BitOrder { #define DEFAULT 1 #define EXTERNAL 0 -// undefine stdlib's abs if encountered -#ifdef abs -#undef abs -#endif // abs - -#ifndef min -#define min(a,b) ((a)<(b)?(a):(b)) -#endif // min - -#ifndef max -#define max(a,b) ((a)>(b)?(a):(b)) -#endif // max - -#define abs(x) ((x)>0?(x):-(x)) #define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt))) -#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5)) + #define radians(deg) ((deg)*DEG_TO_RAD) #define degrees(rad) ((rad)*RAD_TO_DEG) #define sq(x) ((x)*(x)) @@ -106,8 +107,4 @@ typedef bool boolean ; typedef uint8_t byte ; -#ifdef __cplusplus -} // extern "C" -#endif // __cplusplus - #endif /* _WIRING_CONSTANTS_ */ diff --git a/platform.txt b/platform.txt index 5b20d5cbec..7798f9c0e0 100644 --- a/platform.txt +++ b/platform.txt @@ -28,7 +28,7 @@ compiler.c.elf.flags=-mthumb {build.flags.optimize} {build.flags.ldspecs} -Wl,-- compiler.S.cmd=arm-none-eabi-gcc compiler.S.flags=-mthumb -c -x assembler-with-cpp {compiler.stm.extra_include} compiler.cpp.cmd=arm-none-eabi-g++ -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} +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} compiler.ar.cmd=arm-none-eabi-gcc-ar compiler.ar.flags=rcs 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 recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}" ## Combine gc-sections, archives, and objects -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 +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 ## Create output (.bin file)