0

I am getting the following error when attempting to compile my sketch:

In file included from sketch.ino:24:0: SerialRenderer.h:7: error: expected class-name before '{' token

SerialRenderer.h

#ifndef SERIALRENDERER_H_
#define SERIALRENDERER_H_

#include <MenuSystem.h>

class SerialRenderer : public MenuComponentRenderer
{
public:
    SerialRenderer();
    virtual ~SerialRenderer();

public: // methods from MenuComponentRenderer
    virtual void render(Menu const& menu) const;
    virtual void render_menu_item(MenuItem const& menu_item) const;
    virtual void render_back_menu_item(BackMenuItem const& menu_item) const;
    virtual void render_numeric_menu_item(NumericMenuItem const& menu_item) const;
    virtual void render_menu(Menu const& menu) const;
};

#endif // SERIALRENDERER_H_

The contents of MenuSystem.h can be found at https://github.com/jonblack/arduino-menusystem/blob/master/MenuSystem.h.

It seems like the include of MenuSystem.h does not happen when SerialRenderer.h is included from my main sketch file. I get the same error if the include in SerialRenderer.h is removed.

Is there something simple I am missing for the compiler to be able to "see" MenuSystem.h?

EDIT:

Turns out I was looking at a newer version of the arduino-menusystem library than I had installed (version 2.1.1). That version did not have a class called MenuComponentRenderer.

I pulled the latest version from https://github.com/jonblack/arduino-menusystem/tree/master and it compiles fine.

1 Answer 1

0

It is most likely caused by the fact that a correct version of MenuSystem library is not properly installed. Check whether you can add the library to your sketch.

EDIT: added that also the version should be correct

4
  • I can include the library in my sketch via Sketch > Include Library. Also Library Manager shows that version 2.1.1 is installed. Commented Jun 18, 2016 at 15:19
  • Rembember to add the include to the sketch. The build will look at the sketch includes to add the necessary paths. Commented Jun 18, 2016 at 16:52
  • @MikaelPatel My main sketch is including both SerialRenderer.h and MenuSystem.h, but I get the same error whether or not MenuSystem.h is included. Commented Jun 19, 2016 at 13:07
  • Indeed the version is also important. Commented Jun 19, 2016 at 16:08

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.