" 'String' does not name a type" in header file

I am trying to create a class, but it keeps telling me 'String' does not name a type! Is this problem because it is a header file (.h)? Thansk.

#define VALUECAP 6

class osc {
public:
  String _message;
  float values[VALUECAP];
};

Did you
#include <WProgram.h>

Thanks. It fixed my problem. What exactly does including wprogram do?

Nate711:
Thanks. It fixed my problem. What exactly does including wprogram do?

If you look at the actual files, WProgram.h includes WString.h, which defines String.

OK, but why do .pde's not need that include? I'm no expert at C btw.

The arduino IDE sticks some things into your code before it sends it to the compiler.

If you're interested in exactly what it does, you can hold shift while compiling to get a verbose output. This will show exactly what functions it calls. It also gives a path to where the temporary files are (they're only there until you hit the upload button), where you can look at everything. The "yoursketch.cpp" file is the "post-arduino processed" file that is sent to the compiler. It includes "#include<WProgram.h>" and then declarations for all the functions you defined (they look like "void loop();")

You may include "Arduino.h" instead of "WProgram.h" . That will also work.

1 Like