Hello folks,
i have been running into a strange problem i don´t understand.
For a network based project i wrote 3 different sketches which share a common logic for data exchange. When i tried to organize my code into seperate filed i ran into some errors which i cant explain because on 1 of the 3 sketches i can compile without errors and the rest complains if there was no function on top of my file. After some testing i narrowed down the problem:
main file
#include "struct.h"
#include <WSWire.h>
void setup() {
}
void loop() {
}
#ifndef struct_h
#define struct_h
#define EEPROM_ID 1
struct EEPROM
{
byte pas_magnets;
byte wheel_magnets;
unsigned int circumference;
unsigned long milage;
unsigned int throt_in_min;
unsigned int throt_in_max;
unsigned int throt_out_min;
unsigned int throt_out_max;
unsigned int voltage_divider;
unsigned int shunt;
byte throt_out_low[16];
byte throt_out_high[16];
};
#define DRIVE_ID 2
struct DRIVE
{
unsigned int pas_rpm;
unsigned int wheel_tacho;
unsigned int motor_tacho;
unsigned long wheel_rotations;
unsigned int bat_volt;
unsigned int bat_current;
};
#define BMS_ID 3
struct BMS
{
unsigned int cells[13];
unsigned int bms_total_voltage;
unsigned int current;
unsigned int rsense;
byte cellreference; //1.22 for cell type 0/1, for 2/3 0.61
byte cellcount;
boolean bms_mode;
};
#define LCD_REQ_ID 4
struct LCD_REQ
{
unsigned int cruise_speed;
byte drive_mode;
};
#define OK_ID 5
struct OK
{
boolean state;
};
#endif
The begin of the working sketch
#include "U8glib.h"
#include "templates.h"
#include <SPI.h>
//i2c
#include <WSWire.h>
#include "struct.h"
When i put
#include <SPI.h>
on top of my testsketch it compiles without errors, else i get:
In file included from fail.ino:1:
struct.h:8: error: 'byte' does not name a type
struct.h:9: error: 'byte' does not name a type
struct.h:18: error: 'byte' does not name a type
struct.h:19: error: 'byte' does not name a type
struct.h:40: error: 'byte' does not name a type
struct.h:41: error: 'byte' does not name a type
struct.h:42: error: 'boolean' does not name a type
struct.h:49: error: 'byte' does not name a type
struct.h:55: error: 'boolean' does not name a type
Can anybody explain this to me ? (Using 1.05)
Thanks in advance