user3132653
user3132653

Reputation: 1

"invalid type argument of unary '*' C

I'm relatively new to to programming and even after doing a thorough research I am not able to solve this problem.

I want to check whether through an object [defined as of variable type union] I can compare with a new object entered by the user for the entered object is in this particular set or not, but always two errors are popping up: "invalid type argument of unary '*' (have 'Object')"

bool is_element_of(Object items, SET*S)
{
  LIST*scan = *S;
  int p = 0;
  while (S != NULL)
  {
    if (*scan->item == items)
      p = 1;
    scan = scan->next;
  }
  if (p == 1)
    return true;
  else
    return false;
}

here is the struct definition along with the union of the object:

typedef struct object
{
  union
  {
    char c;
    char t[OSIZE];
    unsigned long int h[OSIZE];
    unsigned int i;
    float f;
    long double j[OSIZE];
    int type;
  } TYPE;
} Object;

typedef struct list1
{
  Object item;
  struct list1*next;
} LIST;

typedef LIST*SET;

Upvotes: 0

Views: 773

Answers (1)

sepp2k
sepp2k

Reputation: 370122

if (*scan->item == items)

scan->item is an Object, not a pointer. So you can't dereference it.

Upvotes: 2

Related Questions