简体   繁体   中英

arduino c++ issues regarding class name

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?

check the compiler settings...it might be possible that it tries to compile c++ code with ac 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)

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM