C incompatible Types struct return

2019-08-04 18:07发布

问题:

The following code gives me a Compile error "incompatible types at assignment"

File 1:

struct a{
  int b;
}

File 2:

static struct a c;

void test(){
   c.b = 0;
}

struct a getStruct(){
   test();
   return c;
}

File 3:

static struct a d;

void setStruct(){
   d = getStruct(); (<-- Error)
}

I've searched for this and can't find my mistake.

标签: c struct