Pages: [1]   Go Down
Author Topic: " 'String' does not name a type" in header file  (Read 1112 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Code:
#define VALUECAP 6

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

Offline Offline
Edison Member
*
Karma: 19
Posts: 1041
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Did you
#include <WProgram.h>
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Fort Lauderdale, FL
Offline Offline
Faraday Member
**
Karma: 71
Posts: 6144
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.c

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Edison Member
*
Karma: 19
Posts: 1041
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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();")
Logged

Pages: [1]   Go Up
Jump to: