NO

Author Topic: error #2168: Operands of '=' have incompatible types ......  (Read 8213 times)

kaschei

  • Guest
error #2168: Operands of '=' have incompatible types ......
« 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

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

Offline AlexN

  • Global Moderator
  • Member
  • *****
  • Posts: 394
    • Alex's Link Sammlung
Re: error #2168: Operands of '=' have incompatible types ......
« Reply #1 on: August 05, 2009, 08:14:45 AM »
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.
CreateStreamOnHGlobal(NULL, TRUE, (IStream **)&stream);
pComCall = *(DWORD **) stream; /*generate error*/

Code: [Select]
pComCall = (DWORD)*(DWORD **) stream;
best regards
 Alex ;)