Reputation: 1
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?
Upvotes: 0
Views: 137
Reputation: 185862
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.
Upvotes: 2
Reputation:
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;
}
Upvotes: 1
Reputation: 55736
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.
Upvotes: 1