Welcome, Guest. Please Login or Register
YaBB - Yet another Bulletin Board
09.02.2010 at 17:15:06
News: Server upgrade went fine, you are now at the new system


Pages: 1
Syntax Error causing boolean / byte to be unknown (Read 2508 times)
lucasvickers
YaBB Newbies
*
Offline

Arduino rocks

Posts: 45
new york
Gender: male
Syntax Error causing boolean / byte to be unknown
02.04.2008 at 02:26:37
 
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)
Code:
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):
Code:
#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:
Code:
#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:
Code:
#include "tank.h"
#include <Wire.h>

 

Back to top
 
 
View Profile   IP Logged
MysteriousAges
Junior Member
**
Offline

Arduino rocks

Posts: 55

Re: Syntax Error causing boolean / byte to be unkn
Reply #1 - 02.04.2008 at 05:45:59
 
Try replacing 'boolean' with 'bool'.
Back to top
 
 
View Profile   IP Logged
wayoda
God Member
*****
Offline



Posts: 662
Wuppertal/Germany
Gender: male
Re: Syntax Error causing boolean / byte to be unkn
Reply #2 - 02.04.2008 at 12:29:35
 
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 :
Code:
#include "WConstants.h"
#include <Wire.h>
#include "tank.h"
 



Eberhard
Back to top
 
 
View Profile   IP Logged
lucasvickers
YaBB Newbies
*
Offline

Arduino rocks

Posts: 45
new york
Gender: male
Re: Syntax Error causing boolean / byte to be unkn
Reply #3 - 02.04.2008 at 14:38:29
 
wayoda wrote on 02.04.2008 at 12:29:35:
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 :
Code:
#include "WConstants.h"
#include <Wire.h>
#include "tank.h"
 



Eberhard


easy enough!  thanks
Back to top
 
 
View Profile   IP Logged
simond
Junior Member
**
Offline

Arduino boulders

Posts: 51
Atlanta, GA
Gender: male
Re: Syntax Error causing boolean / byte to be unkn
Reply #4 - 02.04.2008 at 15:38:05
 
Alternatively you can use the 'bool' datatype, which shouldn't require adding the include.
Back to top
 
 
View Profile   IP Logged
wayoda
God Member
*****
Offline



Posts: 662
Wuppertal/Germany
Gender: male
Re: Syntax Error causing boolean / byte to be unkn
Reply #5 - 02.04.2008 at 17:48:00
 
Hi simond
simond wrote on 02.04.2008 at 15:38:05:
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






Back to top
 
 
View Profile   IP Logged
simond
Junior Member
**
Offline

Arduino boulders

Posts: 51
Atlanta, GA
Gender: male
Re: Syntax Error causing boolean / byte to be unkn
Reply #6 - 02.04.2008 at 18:03:04
 
wayoda wrote on 02.04.2008 at 17:48:00:
Hi simond
simond wrote on 02.04.2008 at 15:38:05:
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.
Back to top
 
 
View Profile   IP Logged
mellis
YaBB Administrator
*****
Offline



Posts: 3006
Cambridge, MA
Re: Syntax Error causing boolean / byte to be unkn
Reply #7 - 02.04.2008 at 18:24:37
 
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.
Back to top
 
 
View Profile | WWW   IP Logged
simond
Junior Member
**
Offline

Arduino boulders

Posts: 51
Atlanta, GA
Gender: male
Re: Syntax Error causing boolean / byte to be unkn
Reply #8 - 02.04.2008 at 19:10:09
 
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.
Back to top
 
 
View Profile   IP Logged
Pages: 1