error #2168: Operands of '=' have incompatible types ......

Started by kaschei, August 04, 2009, 09:49:56 PM

Previous topic - Next topic

kaschei

Hi Pelle. I have code which generate:
error #2168: Operands of '=' have incompatible types 'unsigned long int' and 'unsigned long int *'.

but actually this is not error because code work just fine in other compilers. So my question is can you change this error into warrning? The code is

CreateStreamOnHGlobal(NULL, TRUE, (IStream **)&stream);
pComCall = *(DWORD **) stream; /*generate error*/
.
.
.
.
.

AlexN

Quote from: kaschei on August 04, 2009, 09:49:56 PM
Hi Pelle. I have code which generate:
error #2168: Operands of '=' have incompatible types 'unsigned long int' and 'unsigned long int *'.
but actually this is not error because code work just fine in other compilers. So my question is can you change this error into warrning? The code is
A K&R C-compiler will not even produce a warning of this, because it will convert all types in an other without type checking and you will see what you get. Pelles C has a very strict type-checking. So the argument  a other compiler work with tihs piece of code is in this case not so good.
The error says that you want convert a pointer to an integer without casting. If you want to do this you need a second casting.
Quote from: kaschei on August 04, 2009, 09:49:56 PM
CreateStreamOnHGlobal(NULL, TRUE, (IStream **)&stream);
pComCall = *(DWORD **) stream; /*generate error*/

pComCall = (DWORD)*(DWORD **) stream;
best regards
Alex ;)