diff options
author | Matthijs Kooijman <matthijs@stdin.nl> | 2014-02-18 19:34:04 +0100 |
---|---|---|
committer | Matthijs Kooijman <matthijs@stdin.nl> | 2014-02-19 16:09:29 +0100 |
commit | a2408d154eb9fa3fa9b07cc5a04e9b3744a9f81a (patch) | |
tree | ecd8a80ccdf80774dc26443d49623f4d2c5b5056 /cores/arduino | |
parent | f76c327aae447ca595a428c6783d817ec2f23ed9 (diff) |
Instead of #defining true and false, include stdbool.h
In C++, true and false are language keywords, so there is no need to
define them as macros. Including stdbool.h in C++ effectively changes
nothing. In C, true, false and also the bool type are not available, but
including stdbool.h will make them available.
Using stdbool.h means that we get true, false and the bool type in
whatever way the compiler thinks is best, which seems like a good idea
to me.
This also fixes the following compiler warnings if a .c file includes
both stdbool.h and Arduino.h:
warning: "true" redefined [enabled by default]
#define true 0x1
warning: "false" redefined [enabled by default]
#define false 0x0
This fixes #1570 and helps toward fixing #1728.
This only changed the AVR core, the SAM core already doesn't define true
and false (but doesn't include stdbool.h either).
Diffstat (limited to 'cores/arduino')
-rw-r--r-- | cores/arduino/Arduino.h | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/cores/arduino/Arduino.h b/cores/arduino/Arduino.h index e12ac82..ec1389e 100644 --- a/cores/arduino/Arduino.h +++ b/cores/arduino/Arduino.h @@ -21,6 +21,7 @@ #define Arduino_h #include <stdlib.h> +#include <stdbool.h> #include <string.h> #include <math.h> @@ -43,9 +44,6 @@ void yield(void); #define OUTPUT 0x1 #define INPUT_PULLUP 0x2 -#define true 0x1 -#define false 0x0 - #define PI 3.1415926535897932384626433832795 #define HALF_PI 1.5707963267948966192313216916398 #define TWO_PI 6.283185307179586476925286766559 |