Where is a glossary of compiler errors

Hi All,
I am getting this error during compile Test:32: error: invalid cast from type 'String' to type 'int'
even though the string value I am trying to convert to an integer does have a value ("25")
Can anybody tell me where I can find explanations of compiler errors so I don't have to bug people on this forum with my obvious questions.

regards,
Chris

Can anybody tell me where I can find explanations of compiler errors so I don't have to bug people on this forum with my obvious questions.

There's not really a good place.

Though, in the case of this error message, the problem seems pretty obvious.

invalid cast from type 'String' to type 'int'

Some function, you didn't say which one, but the IDE highlighted the offending line, expects an argument type that does not include String. The nearest (only) overload for that function takes an int. The compiler can not convert a String to an int, since one is a class and the other is a base type.

It does not matter that the string contains only a collection of characters that look to you like an int.

Hi Paul,
I am testing a string variable called 'cmd' to see if it is in a list of acceptable commands input from a console program communicating via the Arduino serial. Checking the switch case function, there is nothing in the documentation that precludes testing string variables, but the compiler reports;Test:32: error: switch quantity not an integer Below is the offending code snippet;

switch (cmd) {// this line is causing the compiler error

//case "20":
//do something
default:
Serial.println("unrecognised command in message");
}// closes off the switch case logic

Once complete there will be up to 20 case lines and program branches.
cmd is a string variable that is loaded with user input commands.

regards,
Chris

Although Visual Basic allows switch case statements with string values, C / C++ does not.

This is probably closer to what you want:

switch (atoi(cmd))
{
     case 20:
         //do something
    default:
        Serial.println("unrecognised command in message");
}

Thanks for the snippet, but the compiler is raising about 20 errors now as it doesn't like the function 'atoi'.
I can't find that function in the Arduino reference either. Are you sure that its not a typo? Maybe it a C++ function that has no equivalent in the Arduino C subset.

switch (atoi(cmd))// THIS LINE IS CAUSING MAJOR DRAMAS
{
case 20:
//do something
default:
Serial.println("unrecognised command in message");
}

Regards,
Chris

atoi() is part of the C standard library but you will need to add

#include <stdlib.h>

at the top of the sketch to make it compile.

Sorry but I don't have access to a C/C++ compiler right now, so I couldn't test.

Hi,
I can't find 'std lib.h' anywhere on my mac, so I am guessing that this is a windows specific library. Surely there must be a native Arduino command to convert a string to an integer. What would be the reverse of Char
(int())?
regards Chris

stdlib.h (note, no space) is not Windows-specific.

Surely there must be a native Arduino command to convert a string to an integer

There is (though it isn't an Arduino "command"); it is called "atoi"