"unsigned short int" is incompatible with parameter type of "unsigned short int *"

Hello dear Forum...
Today Visual Studio 10 is driving me crazy!
I tried to create a pointer (unsigned short int*) and let it point to a Integer (unsigned short int) ..
But for every line of Code I wrote it into, he says
"unsigned short int" is incompatible with parameter type of "unsigned short int *"
It also says "cannot convert parameter 2 from "unsigned short" to "unsigned short"
I encountered many strange errors in VS10 but that one keeps irritating me as I seem to not be able to fix it..
I search around the forums for problems like "static_char*" to "char*" but never saw a problem with the same Variable type.

I hope this isn't one of those "totally stupid and obvious" errors.
Can you post the code the causes the error?
Are you doing something like this?
1
2
unsigned short int i = 5;
unsigned short int* p = i;


You need to use the dereference address-of operator on i to get a pointer that points to i.
unsigned short int* p = &i;
Last edited on
As for your first problem, you need to reference your short:
1
2
int i = 8;
int *pi = &i;


Second issue sounds strange, but probably a missing * or & somewhere.
Last edited on
Just to note, & here is the address-of operator, not the dereference operator (that would be *).
To post it, my code looks a bit like this

1
2
unsigned short int menuPosition=0,profilesNumber=0,*numberOfProfiles;
numberOfProfiles = &profilesNumber;
Last edited on
The fragment you posted compiles for me with no problems on VS2008. Are you sure that's a good representation of what you're trying to do?
Last edited on
Well its written just like that in the Code.

But the debug shows the problem in this call
subMenuOutput << subMenu(menuPosition,*numberOfProfiles);

which in term is declared this way
int subMenu(int chosenSubMenu,unsigned short int *numberOfProfiles)
The fragment you posted compiles for me with no problems on VS2008.
Same for a gcc 89 in UNIX :)

remove the * from numberOfProfiles in your function call. It's already a pointer, which is what the function expects.
Last edited on
Well I can tell you that function call is incorrect; you are dereferencing numberOfProfiles when you call subMenu(), causing you to pass an unsigned short int where it expects a pointer to one.
Last edited on
Ouh yes now it works..
Stupid me. thanks for this one!
I guess I wouldn't have noticed this one myself with those Compiler-Errors.
Again, thanks to all of you.
Topic archived. No new replies allowed.