Go Down

Topic: String(?) error (Read 9 times) previous topic - next topic

Haavard GJ

Hi
was going to compile a program that i copyed off the web, but i get the following error message:

Code: [Select]

C:\arduino-0021\libraries\String\WString.cpp:34: error: prototype for 'String::String(int)' does not match any in class 'String'
C:\arduino-0021\hardware\arduino\cores\arduino/WString.h:39: error: candidates are: String::String(long unsigned int, int)
C:\arduino-0021\hardware\arduino\cores\arduino/WString.h:38: error:                 String::String(long int, int)
C:\arduino-0021\hardware\arduino\cores\arduino/WString.h:37: error:                 String::String(unsigned int, int)
C:\arduino-0021\hardware\arduino\cores\arduino/WString.h:36: error:                 String::String(int, int)
C:\arduino-0021\hardware\arduino\cores\arduino/WString.h:35: error:                 String::String(unsigned char)
C:\arduino-0021\hardware\arduino\cores\arduino/WString.h:34: error:                 String::String(char)
C:\arduino-0021\hardware\arduino\cores\arduino/WString.h:33: error:                 String::String(const String&)
C:\arduino-0021\hardware\arduino\cores\arduino/WString.h:32: error:                 String::String(const char*)
C:\arduino-0021\libraries\String\WString.cpp: In constructor 'String::String(const char*)':
C:\arduino-0021\libraries\String\WString.cpp:50: error: '_array' was not declared in this scope
C:\arduino-0021\libraries\String\WString.cpp:52: error: 'setArray' was not declared in this scope
C:\arduino-0021\libraries\String\WString.cpp: In copy constructor 'String::String(const String&)':
C:\arduino-0021\libraries\String\WString.cpp:60: error: '_array' was not declared in this scope
C:\arduino-0021\libraries\String\WString.cpp:61: error: 'clear' was not declared in this scope
C:\arduino-0021\libraries\String\WString.cpp:62: error: 'const class String' has no member named '_array'
C:\arduino-0021\libraries\String\WString.cpp:62: error: 'setArray' was not declared in this scope
C:\arduino-0021\libraries\String\WString.cpp: In member function 'const String& String::operator=(const String&)':
C:\arduino-0021\libraries\String\WString.cpp:77: error: '_array' was not declared in this scope
C:\arduino-0021\libraries\String\WString.cpp:83: error: 'clear' was not declared in this scope
C:\arduino-0021\libraries\String\WString.cpp:84: error: 'const class String' has no member named '_array'
C:\arduino-0021\libraries\String\WString.cpp:84: error: 'setArray' was not declared in this scope
C:\arduino-0021\libraries\String\WString.cpp: At global scope:
C:\arduino-0021\libraries\String\WString.cpp:90: error: prototype for 'const String& String::operator=(const char*)' does not match any in class 'String'
C:\arduino-0021\libraries\String\WString.cpp:70: error: candidate is: const String& String::operator=(const String&)
C:\arduino-0021\libraries\String\WString.cpp:107: error: prototype for 'const String& String::operator+=(const char*)' does not match any in class 'String'
C:\arduino-0021\hardware\arduino\cores\arduino/WString.h:44: error: candidate is: const String& String::operator+=(const String&)
C:\arduino-0021\libraries\String\WString.cpp:127: error: prototype for 'const String& String::operator+=(char)' does not match any in class 'String'
C:\arduino-0021\hardware\arduino\cores\arduino/WString.h:44: error: candidate is: const String& String::operator+=(const String&)
C:\arduino-0021\libraries\String\WString.cpp:145: error: prototype for 'const String& String::operator+=(int)' does not match any in class 'String'
C:\arduino-0021\hardware\arduino\cores\arduino/WString.h:44: error: candidate is: const String& String::operator+=(const String&)
C:\arduino-0021\libraries\String\WString.cpp:159: error: prototype for 'const String& String::operator+=(long int)' does not match any in class 'String'
C:\arduino-0021\hardware\arduino\cores\arduino/WString.h:44: error: candidate is: const String& String::operator+=(const String&)
C:\arduino-0021\libraries\String\WString.cpp: In member function 'const String& String::operator+=(const String&)':
C:\arduino-0021\libraries\String\WString.cpp:176: error: '_array' was not declared in this scope
C:\arduino-0021\libraries\String\WString.cpp:179: error: 'setArray' was not declared in this scope
C:\arduino-0021\libraries\String\WString.cpp:183: error: '_array' was not declared in this scope
C:\arduino-0021\libraries\String\WString.cpp:183: error: 'const class String' has no member named '_array'
C:\arduino-0021\libraries\String\WString.cpp: At global scope:
C:\arduino-0021\libraries\String\WString.cpp:191: error: no 'const String& String::append(char)' member function declared in class 'String'
C:\arduino-0021\libraries\String\WString.cpp:196: error: no 'const String& String::append(char*)' member function declared in class 'String'
C:\arduino-0021\libraries\String\WString.cpp:201: error: no 'const String& String::append(const String&)' member function declared in class 'String'
C:\arduino-0021\libraries\String\WString.cpp:206: error: no 'const String& String::append(int, int)' member function declared in class 'String'
C:\arduino-0021\libraries\String\WString.cpp:217: error: no 'const String& String::append(long int, int)' member function declared in class 'String'
C:\arduino-0021\libraries\String\WString.cpp:226: error: no 'const String& String::append(int)' member function declared in class 'String'
C:\arduino-0021\libraries\String\WString.cpp:234: error: no 'const String& String::append(long int)' member function declared in class 'String'
C:\arduino-0021\libraries\String\WString.cpp:323: error: prototype for 'char String::charAt(int)' does not match any in class 'String'
C:\arduino-0021\hardware\arduino\cores\arduino/WString.h:57: error: candidate is: char String::charAt(unsigned int) const
C:\arduino-0021\libraries\String\WString.cpp:339: error: prototype for 'void String::setCharAt(int, char)' does not match any in class 'String'
C:\arduino-0021\hardware\arduino\cores\arduino/WString.h:71: error: candidate is: void String::setCharAt(unsigned int, char)
C:\arduino-0021\libraries\String\WString.cpp:355: error: prototype for 'boolean String::equals(char*)' does not match any in class 'String'
C:\arduino-0021\hardware\arduino\cores\arduino/WString.h:60: error: candidate is: unsigned char String::equals(const String&) const
C:\arduino-0021\libraries\String\WString.cpp:366: error: prototype for 'boolean String::equals(const String&)' does not match any in class 'String'
C:\arduino-0021\hardware\arduino\cores\arduino/WString.h:60: error: candidate is: unsigned char String::equals(const String&) const
C:\arduino-0021\libraries\String\WString.cpp:372: error: no 'boolean String::contains(char*)' member function declared in class 'String'
C:\arduino-0021\libraries\String\WString.cpp:380: error: prototype for 'byte* String::getBytes()' does not match any in class 'String'
C:\arduino-0021\hardware\arduino\cores\arduino/WString.h:79: error: candidate is: void String::getBytes(unsigned char*, unsigned int)
C:\arduino-0021\libraries\String\WString.cpp:386: error: no 'void String::setArray(const char*)' member function declared in class 'String'
C:\arduino-0021\libraries\String\WString.cpp:396: error: prototype for 'int String::indexOf(int)' does not match any in class 'String'
C:\arduino-0021\hardware\arduino\cores\arduino/WString.h:65: error: candidates are: int String::indexOf(const String&, unsigned int) const
C:\arduino-0021\hardware\arduino\cores\arduino/WString.h:64: error:                 int String::indexOf(const String&) const
C:\arduino-0021\hardware\arduino\cores\arduino/WString.h:63: error:                 int String::indexOf(char, unsigned int) const
C:\arduino-0021\hardware\arduino\cores\arduino/WString.h:62: error:                 int String::indexOf(char) const
C:\arduino-0021\libraries\String\WString.cpp:402: error: prototype for 'int String::indexOf(const String&)' does not match any in class 'String'
C:\arduino-0021\hardware\arduino\cores\arduino/WString.h:65: error: candidates are: int String::indexOf(const String&, unsigned int) const
C:\arduino-0021\hardware\arduino\cores\arduino/WString.h:64: error:                 int String::indexOf(const String&) const
C:\arduino-0021\hardware\arduino\cores\arduino/WString.h:63: error:                 int String::indexOf(char, unsigned int) const
C:\arduino-0021\hardware\arduino\cores\arduino/WString.h:62: error:                 int String::indexOf(char) const
C:\arduino-0021\libraries\String\WString.cpp:408: error: prototype for 'int String::indexOf(char, int)' does not match any in class 'String'
C:\arduino-0021\hardware\arduino\cores\arduino/WString.h:65: error: candidates are: int String::indexOf(const String&, unsigned int) const
C:\arduino-0021\hardware\arduino\cores\arduino/WString.h:64: error:                 int String::indexOf(const String&) const
C:\arduino-0021\hardware\arduino\cores\arduino/WString.h:63: error:                 int String::indexOf(char, unsigned int) const
C:\arduino-0021\hardware\arduino\cores\arduino/WString.h:62: error:                 int String::indexOf(char) const
C:\arduino-0021\libraries\String\WString.cpp:420: error: prototype for 'int String::indexOf(const String&, int)' does not match any in class 'String'
C:\arduino-0021\hardware\arduino\cores\arduino/WString.h:65: error: candidates are: int String::indexOf(const String&, unsigned int) const
C:\arduino-0021\hardware\arduino\cores\arduino/WString.h:64:
anyone that understands this cryptic message?

PaulS

Quote
was going to compile a program that i copyed off the web

That code, huh?

Quote
anyone that understands this cryptic message?

Nothing cryptic about any of the messages. Terse, perhaps.

Which version of the ODE are you using.The String class got incorporated into the core, and some changes were made,in 0019, I think.

Haavard GJ

#2
Dec 16, 2010, 09:11 pm Last Edit: Dec 16, 2010, 09:14 pm by haavardgj Reason: 1
if i include "wstring" i get all the error messages as written above, but if i dont include them, i get theese message:

Code: [Select]


Arduino_Webserver___VIKTIG.cpp: In function 'void loop()':
Arduino_Webserver___VIKTIG:50: error: 'class String' has no member named 'append'
Arduino_Webserver___VIKTIG:60: error: 'class String' has no member named 'contains'
Arduino_Webserver___VIKTIG:65: error: 'class String' has no member named 'contains'

Haavard GJ

#3
Dec 16, 2010, 09:13 pm Last Edit: Dec 16, 2010, 09:19 pm by haavardgj Reason: 1
and here is the code:
btw: i use version 21
Code: [Select]


//*******************************

#include <SPI.h>
#include <Ethernet.h>

/*
Simple Ethernet Test
Arduino server outputs simple text to browser
and controlling LED with simple checkbox
The circuit:
* Arduino Duemilanove
* Arduino Ethernet shield
* Basic FTDI breakout 5V
* LED connected to GND and digital pin 4 via resistor
By Minde
http://www.sciencprog.com/
*/

byte    mac[] =     { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };   //physical mac address
byte    ip[] =      { 192, 168, 1, 110 };                     // ip in lan
byte    gateway[] = { 192, 168, 1, 1 };                       // internet access via router
byte    subnet[] =  { 255, 255, 255, 0 };                     //subnet mask
Server  server(80);                //server port
byte    sampledata=50;             //some sample data - outputs 2 (ascii = 50 DEC)
int     ledPin = 4;                // LED pin
char    link[]= "";                 //link data
String  readString = String(30);   //string for fetching data from address
boolean LEDON = false;             //LED status flag

void setup()
{    
 Serial.begin(9600); //enable serial datada print
 Ethernet.begin(mac, ip, gateway, subnet); //start Ethernet
 
 pinMode(ledPin, OUTPUT); //Set pin 4 to output
 Serial.print("Starter server");
}

void loop(){

 Client client = server.available();  // Create a client connection
   if (client) {
     while (client.connected()) {
       if (client.available()) {

         char c = client.read();

       if (readString.length() < 30) { //read char by char HTTP request
         readString.append(c); } //store characters to string
         
       Serial.print(c); //output chars to serial port for debugging



       if (c == '\n') { //if HTTP request has ended


         //lets check if LED should be lighted
         if (readString.contains("L=1")) { //led has to be turned ON
             digitalWrite(ledPin, HIGH); // set the LED on
             LEDON = true;
         }

         if (readString.contains("L=0")) {
           //led has to be turned OFF
           digitalWrite(ledPin, LOW); // set the LED OFF
           LEDON = false;
          }


client.println("HTTP/1.1 200 OK"); // now output HTML data starting with standart header
client.println("Content-Type: text/html");
client.println();
client.print  ("<body style=background-color:white>"); //set background to white

// HTML Code

client.println("<font color='red'><h1>HTTP test routines</font></h1>");//send first heading
client.println("<hr />");
client.println("<font color='blue' size='5[ch8242]>Sample data: "); //output some sample data to browser

client.print(sampledata);//lets output some data

client.println("<br />");//some space between lines
client.println("<hr />");
client.println("<font color='green'>Simple table: "); //drawing simple table
client.println("<br />");
client.println("<table border=1><tr><td>row 1, cell 1</td><td>row 1, cell 2</td></tr>");
client.println("<tr><td>row 2, cell 1</td><td>row 2, cell 2</td></tr></table>");

client.println("<br />");
client.println("<hr />");

client.println("<font color='blue' size='5[ch8242]>Link: "); //printing some link
client.print("<a href=");
client.print(link);
client.println(">Visit Scienceprog!</a>");
client.println("<br />");
client.println("<hr />");

//controlling led via checkbox
client.println("<h1>LED control</h1>");

//address will look like http://192.168.1.110/?L=1 when submited
client.println("<form method=get name=LED> <input type='radio' name='L' value='1'>LED ON<br><input type='radio' name='L' value='0'>LED OFF<br><input type=submit value=submit></form>");

client.println("<br />");
//printing LED status
client.print("<font size='5[ch8242]>LED status: ");
 if (LEDON) {
    client.println("<font color='green' size='5[ch8242]>ON");
  }
 else {
   client.println("<font color='grey' size='5[ch8242]>OFF");
  }

client.println("<hr />");
client.println("<hr />");
client.println("</body></html>");
//clearing string for next read
readString="";

//stopping client

client.stop();

}}}}}

PaulS

Quote
btw: i use version 21


Quote
if i include "wstring" i get all the error messages as written above, but if i dont include them, i get theese message:

You should not be including WString.h with 0021.

Quote
The String class got incorporated into the core, and some changes were made,in 0019, I think.

The sample that you are trying to compile was not modified for 0021. You have two choices. One is to compile and link using 0018. The other is to update the code to use the 0021 String class.

Quote
error: 'class String' has no member named 'append'
error: 'class String' has no member named 'contains'

The old names should give you a pretty good hint as to what the functions do. It should not be too difficult to figure out what the replacement function is. I'll give you the first one, though. append becomes concat.

The contains method will require a bit more work, unfortunately. Not terribly difficult, though. Give it a try, and come back if you can't figure it out.

Go Up