Question

I am working on connecting my philips hue light bulbs to the arduino and found some resources online. One of the resources has a file that keeps throwing an error and when I looked at it, I have never seen this syntax used before. Can anyone help me out?

#ifndef SERIALHUE_H
#define SERIALHUE_H
#include <Arduino.h>
#include <Stream.h>
#include <ArduinoHue.h>



class SerialHue: public ArduinoHue{
 public:
SerialHue(char* ipAddress, Stream* serial);
boolean connect(char* deviceId, char* username);
 protected:
char* _ipAddress; 
char* _deviceId;
char* _username;
boolean makePost(char* request, char* data);
boolean waitForResponse();
Stream* _serial;
};

#endif

The error is in this line:

*class SerialHue: public ArduinoHue{*

Giving the error:

SerialHue.h:10: error: expected class-name before '{' token

What is this format and what is wrong here?

Was it helpful?

Solution

check the compiler settings...it might be possible that it tries to compile c++ code with a c compiler

about the format:

class X : public Y {
}

is the syntax of extending a class in C++

plus: check that ArduinoHue.h really defines ArduinoHue class

...if you can't figure it out: take a look at the precompiled sourcefile (g++ -E)

OTHER TIPS

First, make sure that you are not recursively including a file, like #including a file that #includes other files you have also #included.

Also, Forward declarations instead of #include ArduinoHue.h could solve your problem. such as:

class ArduinoHue;

I have found similar questions, they might be able to help you:
expected class-name before '{' token

error: expected class-name before ‘{’ token

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top