From 90a4f4bb9a26e94407d6fbaf2ed561451f254965 Mon Sep 17 00:00:00 2001 From: Christopher Andrews Date: Mon, 30 Jun 2014 22:42:24 +1000 Subject: [PATCH 1/3] Modified Arduino.h with changes to the boolean type As the Arduino specific boolean type is dangerous in C++, I have implemented a fix to solve the situation for both C and C++ There is also no need for stdbool, it also defines true and false, which is not needed or allowed in a C++ context. --- hardware/arduino/avr/cores/arduino/Arduino.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/hardware/arduino/avr/cores/arduino/Arduino.h b/hardware/arduino/avr/cores/arduino/Arduino.h index ec1389e1426..e27e35642c1 100644 --- a/hardware/arduino/avr/cores/arduino/Arduino.h +++ b/hardware/arduino/avr/cores/arduino/Arduino.h @@ -21,7 +21,7 @@ #define Arduino_h #include -#include +//#include #include #include @@ -31,6 +31,14 @@ #include "binary.h" +#ifdef __cplusplus + typedef bool boolean; +#else + typedef uint8_t boolean; + #define false 0 + #define true !false +#endif + #ifdef __cplusplus extern "C"{ #endif @@ -114,7 +122,7 @@ typedef unsigned int word; #define bit(b) (1UL << (b)) -typedef uint8_t boolean; +//typedef uint8_t boolean; typedef uint8_t byte; void init(void); From 401d8f7536ab7354d6832746a9812388982c935a Mon Sep 17 00:00:00 2001 From: Christopher Andrews Date: Mon, 30 Jun 2014 23:55:15 +1000 Subject: [PATCH 2/3] Removed unnecessary comments from previous commit. --- hardware/arduino/avr/cores/arduino/Arduino.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/hardware/arduino/avr/cores/arduino/Arduino.h b/hardware/arduino/avr/cores/arduino/Arduino.h index e27e35642c1..83a6d2c4ac9 100644 --- a/hardware/arduino/avr/cores/arduino/Arduino.h +++ b/hardware/arduino/avr/cores/arduino/Arduino.h @@ -21,7 +21,6 @@ #define Arduino_h #include -//#include #include #include @@ -122,7 +121,6 @@ typedef unsigned int word; #define bit(b) (1UL << (b)) -//typedef uint8_t boolean; typedef uint8_t byte; void init(void); From 4fc228e69b935fd13f7cdf0c7c4feb3ba2e36f57 Mon Sep 17 00:00:00 2001 From: Christopher Andrews Date: Sun, 13 Jul 2014 19:54:50 +1000 Subject: [PATCH 3/3] Added support for C++11 iterators. This update will allow the String class to be used in a range based for loop. --- hardware/arduino/avr/cores/arduino/WString.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hardware/arduino/avr/cores/arduino/WString.h b/hardware/arduino/avr/cores/arduino/WString.h index 74024309278..fd106af2747 100644 --- a/hardware/arduino/avr/cores/arduino/WString.h +++ b/hardware/arduino/avr/cores/arduino/WString.h @@ -62,6 +62,8 @@ class String #ifdef __GXX_EXPERIMENTAL_CXX0X__ String(String &&rval); String(StringSumHelper &&rval); + auto begin() -> const char* { return c_str(); } + auto end() -> const char* { return c_str() + length(); } #endif explicit String(char c); explicit String(unsigned char, unsigned char base=10);