views:

104

answers:

3

OK, i have a strange problem. I have this piece of code:

int *p;
int test;
p=&test;

In Visual C++ express, in my exsisting project, I get this error:

missing type specifier - int assumed.
'p' : 'int' differs in levels of indirection from 'char *'
'initializing' : cannot convert from 'char *' to 'int'

But when i create new project, same code is fine. Whats the problem please?

+1  A: 

If the same code on different projects produces different results, I guess you can assume the problem isn't with the code, but with the project.

I suggest you make a diff between the two project files to have a quick look over what could be wrong.

ereOn
+1  A: 

Have you placed that code inside a function? You cannot write arbitrary C++ code outside of functions.

int main() {
    int *p;
    int test;
    p=&test;
}
anon
+2  A: 

Something preceding this code may be breaking things (more context might help). Perhaps test is a macro that wreaks havoc with the meaning of your code.

Marcelo Cantos