"Test is not a class or namespace name" simple VS2010 hassle

Hey, I'm not a fan of the VS IDE but in this particular case I have to use it. The offending code can be simplified as far as the below, there is no reason in standard C++ that this would not work, therefore I cannot see the issue.

1
2
3
4
5
6
7
class Test
{
public:
   static int yo;
};

int Test::yo = 1;


Compiler messages:
dllmain.cpp(4): error C3872: '0x2028': this character is not allowed in an identifier
1>dllmain.cpp(4): error C3872: '0x2028': this character is not allowed in an identifier
1>dllmain.cpp(4): error C3872: '0x2028': this character is not allowed in an identifier
1>dllmain.cpp(4): error C2065: '
' : undeclared identifier
1>dllmain.cpp(4): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>dllmain.cpp(4): error C2144: syntax error : 'int' should be preceded by ';'
1>dllmain.cpp(4): error C3872: '0x2028': this character is not allowed in an identifier
1>dllmain.cpp(4): error C2143: syntax error : missing ';' before '}'
1>dllmain.cpp(4): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>dllmain.cpp(4): error C3872: '0x2028': this character is not allowed in an identifier
1>dllmain.cpp(5): error C2144: syntax error : 'int' should be preceded by ';'
1>dllmain.cpp(5): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>dllmain.cpp(5): error C2653: 'Test' : is not a class or namespace name


Notice the "this character is not allowed in an identifier", could it be the encoding of the file, or is the last error message the cause, incorrect syntax?

I'm baffled why this simple piece of code will not work in Visual Studio.

Thanks. =\
Krisando
Notice the "this character is not allowed in an identifier", could it be the encoding of the file

That's what I was thinking too. Maybe try to copy the code to a raw text editor (like notepad) and back. Or better yet, just edit the files from there.

Also this code has a main function right?
Last edited on
int Test::yo = 1;
Thanks for your opinion Mathhead200, since you agreed it could be the encoding I tried Unix encoding and not only did it work, it displayed properly again in another IDE (Codeblocks).
I'm glad it worked Krisando.
Topic archived. No new replies allowed.