does not name a Type. (But it does elsewhere)

I have this large program I'm working on and I use a class called keyboard. In a second part of this large program I wanted to use that class again but now, it does not name a type. Odd, seems to work fine where it is first used.

Anyway after all evening fighting this I broke it out into the simplest .ino and Lib files I cold and.. Still does not name a type.

The .ino

#include <label.h>
#include "keystroke.h"
#include "editField.h"
#include "idlers.h"
#include "keyboard.h"
#include <drawDelete.h>
#include <enterArrow.h>

keyboard*       ourKeyboard;

void setup() {
  
  ourKeyboard = newkeyboard(NULL);
}

void loop() {
  idle();
}

The errors..

Arduino: 1.8.7 (Mac OS X), TD: 1.44, Board: "Teensy 3.2 / 3.1, Serial, 72 MHz, Faster, US English"

keyboard_test:10: error: 'keyboard' does not name a type
 keyboard*       ourKeyboard;
 ^
keyboard_test: In function 'void setup()':
keyboard_test:14: error: 'ourKeyboard' was not declared in this scope
   ourKeyboard = newkeyboard(NULL);
   ^
keyboard_test:14: error: 'newkeyboard' was not declared in this scope
   ourKeyboard = newkeyboard(NULL);
                                 ^
Multiple libraries were found for "SD.h"
 Used: /Applications/Arduino.app/Contents/Java/hardware/teensy/avr/libraries/SD
 Not used: /Applications/Arduino.app/Contents/Java/libraries/SD
Multiple libraries were found for "gfxfont.h"
 Used: /Users/Dads/Documents/Arduino/libraries/Adafruit-GFX
 Not used: /Applications/Arduino.app/Contents/Java/hardware/teensy/avr/libraries/ssd1351
 Not used: /Applications/Arduino.app/Contents/Java/hardware/teensy/avr/libraries/Adafruit_GFX
 Not used: /Applications/Arduino.app/Contents/Java/hardware/teensy/avr/libraries/ssd1351
 Not used: /Applications/Arduino.app/Contents/Java/hardware/teensy/avr/libraries/Adafruit_GFX
 Not used: /Applications/Arduino.app/Contents/Java/hardware/teensy/avr/libraries/ssd1351
 Not used: /Applications/Arduino.app/Contents/Java/hardware/teensy/avr/libraries/Adafruit_GFX
 Not used: /Applications/Arduino.app/Contents/Java/hardware/teensy/avr/libraries/ssd1351
 Not used: /Applications/Arduino.app/Contents/Java/hardware/teensy/avr/libraries/Adafruit_GFX
Multiple libraries were found for "Adafruit_ILI9341.h"
 Used: /Users/Dads/Documents/Arduino/libraries/Adafruit_ILI9341
 Not used: /Applications/Arduino.app/Contents/Java/hardware/teensy/avr/libraries/Adafruit_ILI9341
'keyboard' does not name a type

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

I'll post the .h & .cpp on the next post.
Thanks!

-jim lee

Here's the source.. Well, the .h

Keyboard.h

#ifndef keyboard_h
#define keyboard_h

#include <label.h>
#include "keystroke.h"
#include "editField.h"
#include "idlers.h"


#define KEY_WD  23
#define KEY_HT  23

#define COL_1   1
#define COL_SP  1

#define ROW_1   210
#define ROW_SP  4

// Keys need to know the state of the keyboard. When they get time
// they'll check the keyboard to see what state things are in and
// redraw themselves accordingly. also output their data accordingly.


enum  keyStates { chars, shifted, numbers, symbols };

class keyboard;

struct keyColors {
 colorObj inputKeyText;
 colorObj inputKeyBase;
 colorObj inputKeyHText;
 colorObj inputKeyHBase;
 
 colorObj contolKeyText;
 colorObj contolKeyBase;
 colorObj contolKeyHText;
 colorObj contolKeyHBase;
 
 colorObj deleteKeyText;
 colorObj deleteKeyBase;
 colorObj deleteKeyHText;
 colorObj deleteKeyHBase;
};

extern keyColors kbPallette;


class keyboardKey : public idler {

  public:
          keyboardKey(keyboard* inKeyboard);
  virtual ~keyboardKey(void);

          keyboard*   mKeyboard;  // Master!
          keyStates   mState;     // Current state I'm showing.
          char        mChar;
          char        mNum;
          char        mSymbol;
          keyCommands mCom;
};


// inputKeys are for inputting data. Like letters & numbers.
class inputKey : public keyboardKey, public label {

  public:
          inputKey(char* inLabel,char* inNum,char* inSym,word locX, word locY,byte width,byte height,keyboard* inKeyboard);
  virtual ~inputKey(void);

  virtual void    idle();     // Use this to keep updated.
  virtual void    drawSelf(void);
  virtual void    doAction(void);
};


// controlKeys are for doing everything else. Like shift, delete and arrow keys.
class controlKey : public keyboardKey, public label {

  public:
          controlKey(char* inLabel,keyCommands inCom,word locX, word locY,byte width,byte height,keyboard* inKeyboard);
  virtual ~controlKey(void);

  virtual void    drawSelf(void);
  virtual void    handleShift(void); 
  virtual void    handleNumber(void);
  virtual void    doAction(void);
};


class keyboard {

 public:
 keyboard(editField* inEditField);
 virtual ~keyboard(void);

 virtual void handleKey(char inChar);
 virtual void handleKey(keyCommands inEditCom);
 virtual void handleKey(keyStates inState);
 virtual void setEditField(editField* inField);
 virtual keyStates getState(void);
 
          editField* mEditField;
          keyStates mState;
          
          inputKey*   qKey;
          inputKey*   wKey;
          inputKey*   eKey;
          inputKey*   rKey;
          inputKey*   tKey;
          inputKey*   yKey;
          inputKey*   uKey;
          inputKey*   iKey;
          inputKey*   oKey;
          inputKey*   pKey;
          
          inputKey*   aKey;
          inputKey*   sKey;
          inputKey*   dKey;
          inputKey*   fKey;
          inputKey*   gKey;
          inputKey*   hKey;
          inputKey*   jKey;
          inputKey*   kKey;
          inputKey*   lKey;
          
          inputKey*   zKey;
          inputKey*   xKey;
          inputKey*   cKey;
          inputKey*   vKey;
          inputKey*   bKey;
          inputKey*   nKey;
          inputKey*   mKey;
          
          inputKey*   spcKey;
          
          controlKey* shiftKey;
          controlKey* backSpKey;
          controlKey* leftArrow;
          controlKey* rightArrow;
          controlKey* symbolKey;
          controlKey* enterKey;
}; 


#endif

Fine, I can't fit in the .cpp

Here's the git link to it.

I'ts missing..

I see it here on my local files but its not on git..

Hang on. Something really weird is going on here..

OK.. Here is a git link : Git link for keyboard.cpp
-jim lee

newkeyboard(NULL)
What happens when you put a space between new and keyboard?

Seems it not a code problem. Its something weird going on with the IDE. I pulled all the keyboard files into a folder with a test program. That revealed that the IDE just wasn't compiling the libraries anymore. I'd done edits here and there in the libraries and it hadn't picked up on them until I moved things around. Suddenly there were all these typos I'd missed and never been told about. Cleaned them up and everything compiled fine.

Wonderful, so I packed this set into its own folder LC_keyboard dumped it into the library folder and.. The error comes back. Not a type, and we ain't telling you why. If they are in the folder with the .ino, everything is fine.

I can add errors to the file, and they never turn up. Its like its just not compiling the libraries anymore.

No one's seen anything like this?

PS Yeah I caught the missing space. :slight_smile:

-jim lee

I'm not familiar with Arduino on Mac (or Mac at all really), but I would have thought you have something misconfigured since this is really basic functionality that should just work.

Things to try:
Close all instances of the Arduino IDE and then restart and try again.
Turn on verbose output during compilation to see if there is any additional info.
Manually install some other random library into the same folder to see if it compiles.

My guess is that the compiler is including the built-in "Keyboard.h" instead of your private "Keyboard.h". That would leave your "class keyboard;" undefined and thus the:

keyboard_test:10: error: 'keyboard' does not name a type
 keyboard*       ourKeyboard;
 ^
keyboard_test: In function 'void setup()':
keyboard_test:14: error: 'ourKeyboard' was not declared in this scope
   ourKeyboard = newkeyboard(NULL);
   ^

Good thought. I tried changing the class name, but not the filename itself. I'll change it and see what happens.

-jim lee

Give that man a cigar!

Not only some filename conflict, but a teensy filename conflict. I decided to force a recompile of my libraries changing to compiling for a UNO. And it sailed right through. Swapping back to my teensy, no go. Then I switched the filename to scrKeyboard.h and everything seems to work now.

THANK YOU VERY MUCH!

-jim lee