How to correctly use functions that return pointers to multiple typedef'ed types in Arduino IDE?
The Arduino IDE, rather annoyingly, tries to "help" you by generating function prototypes for functions, something it sometimes fails to do.

You can make your code compile by adding one yourself:

typedef struct {
  int x1;
} x;

x *a;

x *f(void) {
  return a;    
}

typedef struct {
    int  y1;
} y;


y *b;     

y *g(void);    // &lt;------------------ ADD THIS
y *g(void) {
  return b;
}


void loop(void) {

}

void setup(void) {

}


I have a post about how to avoid the quirks in the IDE which may help you.

If you just move your code into a separate .CPP file and leave the main sketch blank, it will compile, if you add this line to the start of the .CPP file:

#include &lt;Arduino.h&gt;


The Arduino IDE uses gcc, so it isn't a problem with the compiler exactly, it is a problem with how it "helps" you.