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).
This commit is contained in:
Matthijs Kooijman 2014-02-18 19:34:04 +01:00
parent f76c327aae
commit a2408d154e
1 changed files with 1 additions and 3 deletions

View File

@ -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