GPJFK
GPJFK

Reputation: 1

Operand types are incompatible "int*" and "int"

I've been getting this error, I don't understand the problem in my code

//prior to this there is a menu selection where you choose a version

if (&config_system.item.Antiaimtypedsy == 2 || &config_system.item.Antiaimtypedsy == 3)

and here is the declared variable

int Antiaimtypedsy; 

LMK what I need to change I am so confused and have been stuck on this.

edit: The error is in the ==

Upvotes: 0

Views: 3237

Answers (2)

user10957435
user10957435

Reputation:

You're using & which is the address of operator. That will give a pointer to the value, which will be an int*. As you found out, you can't properly compare an int and an int*.

Just use the int itself instead:

if (config_system.item.Antiaimtypedsy == 2 || config_system.item.Antiaimtypedsy == 3)

Upvotes: 1

tadman
tadman

Reputation: 211690

You don't need to take the address of the value, you just need the value. Additionally, if you need to compare it against multiple possibilities, use switch:

switch (config_system.item.Antiaimtypedsy) {
  case 2:
  case 3:
    // ...
    break;
}

The error is not ==, it's the incorrect types caused by &.

Upvotes: 2

Related Questions