When I try to compile this:
void *BaseEnt::GetVar(char const *varname)
{
char name = *varname;
switch(name)
{
case "id":
return (void*)id;
case "name":
return (void*)name;
case "count":
return (void*)count;
default:
return (void*)NULL;
}
}
I get these errors:
------ Build started: Project: Test Classes, Configuration: Debug Win32 ------
Compiling...
classes.cpp
c:\documents and settings\tom\my documents\visual studio 2008\projects\test classes\test classes\classes.cpp(25) : error C2051: case expression not constant
c:\documents and settings\tom\my documents\visual studio 2008\projects\test classes\test classes\classes.cpp(27) : error C2051: case expression not constant
c:\documents and settings\tom\my documents\visual studio 2008\projects\test classes\test classes\classes.cpp(29) : error C2051: case expression not constant
c:\documents and settings\tom\my documents\visual studio 2008\projects\test classes\test classes\classes.cpp(33) : warning C4065: switch statement contains 'default' but no 'case' labels
Build log was saved at "file://c:\Documents and Settings\tom\My Documents\Visual Studio 2008\Projects\Test Classes\Test Classes\Debug\BuildLog.htm"
Test Classes - 3 error(s), 1 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I thought that things like "id" were constant because they're a litteral?
Any help would be appreciated.
PS. If you need more information on my problem, feel free to ask.