Syntax Error causing boolean / byte to be unknown

I am sure it is some syntax I am doing. Oddly enough, if I change all the booleans to say, longs, it compiles ok.

I removed the logic out of the .cpp and the main file to make my troubleshooting easier.

At this point I am stuck, so any help is appreciated.
This is all in Arduino 11

error:
(more or less saying every byte and boolean definition is an issue)

C:\arduino-0011-win\tmp\/tank.h:24: error: 'boolean' does not name a type


C:\arduino-0011-win\tmp\/tank.h:25: error: 'boolean' does not name a type


C:\arduino-0011-win\tmp\/tank.h:26: error: 'boolean' does not name a type


C:\arduino-0011-win\tmp\/tank.h: In constructor 'deviceStatus::deviceStatus()':


C:\arduino-0011-win\tmp\/tank.h:29: error: 'powerON' was not declared in this scope


C:\arduino-0011-win\tmp\/tank.h:30: error: 'environmentOK' was not declared in this scope


C:\arduino-0011-win\tmp\/tank.h:31: error: 'programmingError' was not declared in this scope


C:\arduino-0011-win\tmp\/tank.h: At global scope:


C:\arduino-0011-win\tmp\/tank.h:38: error: 'boolean' does not name a type


C:\arduino-0011-win\tmp\/tank.h:57: error: variable or field 'writeLEDMask' declared void


C:\arduino-0011-win\tmp\/tank.h:57: error: 'byte' was not declared in this scope


C:\arduino-0011-win\tmp\/tank.h:63: error: 'boolean' does not name a type


C:\arduino-0011-win\tmp\/tank.h:64: error: 'boolean' does not name a type


C:\arduino-0011-win\tmp\/tank.h:67: error: 'boolean' does not name a type

.pde (main window):

#include <Wire.h>
#include "tank.h"

//remove later, for testing
byte mask1 = B10101010;
byte mask2 = B01010101;

//used to toggle status light
long counter = 0;
byte statusMask;

char* dow[7] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

 

void setup() {

  Wire.begin();
  Serial.begin(9600);

  // shift register (LED) outputs
  pinMode(SHIFT_REGISTER_CLOCK, OUTPUT);
  pinMode(SHIFT_CLOCK, OUTPUT);
  pinMode(SHIFT_OUT, OUTPUT);
  
  pinMode(LIGHT_POWER, OUTPUT);
  pinMode(HUM_POWER, OUTPUT);
}

void loop() {

}

.h:

#define SHIFT_OUT                4
#define SHIFT_REGISTER_CLOCK     5
#define SHIFT_CLOCK              6

#define SENSOR_CLOCK             2
#define SENSOR_DATA              3

#define LIGHT_POWER              7
#define HUM_POWER                8

#define readHumMask              B00000101
#define readTempMask             B00000011
#define clearMask                B00011110
#define readStatusMask           B00000111
#define writeStatusMask          B00000110
#define softResetMask            B00011110
#define heatOn                   B00000100
#define heatOff                  0



class deviceStatus {
  public:
    boolean powerON;
    boolean environmentOK;
    boolean programmingError;
  
  deviceStatus() {
    powerON = false;
    environmentOK = false;
    programmingError = false;
  }
};

typedef struct {
  double temp;
  double humidity;
  boolean readError;
} envStatus;


typedef struct {
  int hour;
  int minute;
  int second;
  int month;
  int day_of_week;
  int day;
  int year;
} time;


// TIME
void readTime(time *retTime);

// STATUS DISPLAY
void writeLEDMask(byte mask);

// SHT15
void readSensor(envStatus *retEnv);
double convertHumidity(int data);
double convertTemperature(int data);
boolean turnHeatOn();
boolean turnHeatOff();
int readMeasurement();
int readRegister();
boolean writeByte(byte output);
int readByte();
int shiftIn();
void transmissionStart();
void clearInterface();

.cpp:

#include "tank.h"
#include <Wire.h>

Try replacing 'boolean' with 'bool'.

Hi,

the datatype boolean is arduino-(wiring-) specific.
To use "boolean" it in a library you must include the file "WConstants.h" into your cpp-file before "tank.h" that is using the datatype.

Start the cpp-file with :

#include "WConstants.h"
#include <Wire.h>
#include "tank.h"

Eberhard

Hi,

the datatype boolean is arduino-(wiring-) specific.
To use "boolean" it in a library you must include the file "WConstants.h" into your cpp-file before "tank.h" that is using the datatype.

Start the cpp-file with :

#include "WConstants.h"

#include <Wire.h>
#include "tank.h"




Eberhard

easy enough! thanks

Alternatively you can use the 'bool' datatype, which shouldn't require adding the include.

Hi simond

Alternatively you can use the 'bool' datatype, which shouldn't require adding the include.

its true, but if you look at the things that get included with "WConstants.h" (which includes "wiring.h" ) you'll see that almost every arduino-specific function are defined here.

So if you are new to the Arduino, its best to include "WProgram.h" (which in turn includes "WConstants.h") to gain access to functions like digitalWrite(), shiftOut() etc.

I would suggest everybody should at least once have a look at the files
arduino-0011/hardware/cores/arduino/wiring.h WConstants.h WProgram.h
to see whats defined in them.

Eberhard

Hi simond

Alternatively you can use the 'bool' datatype, which shouldn't require adding the include.

its true, but if you look at the things that get included with "WConstants.h" (which includes "wiring.h" ) you'll see that almost every arduino-specific function are defined here.

So if you are new to the Arduino, its best to include "WProgram.h" (which in turn includes "WConstants.h") to gain access to functions like digitalWrite(), shiftOut() etc.

I would suggest everybody should at least once have a look at the files
arduino-0011/hardware/cores/arduino/wiring.h WConstants.h WProgram.h
to see whats defined in them.

Eberhard

No argument here. The bigger question is why WProgram.h isn't being included by default during compilation. It certainly wasn't explicitly necessary under 0010.

It is included in your main sketch file. It's not included in other .cpp, .c, or .h files, under the assumption that if you're using them, you know what you're doing (or aren't afraid to ask for help), and you don't want the Arduino pre-processor messing with your code.

Of course, which is why I thought it odd. If tank.h is being processed as part of the main .pde, and WProgram.h is included before tank.h, there should be no error. I had not caught the extra .cpp file in my first reading.